Using uv to run Python tools without installing them

Posted on Thu 23 January 2025 in python, uv • Tagged with python, uv

I wanted to run a Python tool without installing it, or preparing a virtual environment and all that. This is now very easy with uv, using uvx.

I wanted to run markitdown, a tool to convert various files to Markdown. I didn't want to install it, so I used uvx:

uvx markitdown "file_to_convert.docx" > output_file.md

It downloads the tool and installs it in a temporary, isolated environment.

A tool can be installed with uv tool install, like this:

uv tool install markitdown

It's very convenient.


Essential git cheat sheet for loners

Posted on Wed 22 January 2025 in git • Tagged with git

This are the basic commands to operate with git as a loner: no branches, no remotes, no merges... Just the basic stuff.

The minimum concepts you need to know are:

  • Git is a version control system. It allows you to store changes in your files. Don't mix it with GitHub, which is a platform to store your repositories.
  • Working directory: the directory where you are working.
  • Staging area: a place to store changes before committing them.
  • Repository: the place where the changes are stored.
  • Commit: a set of changes stored in the repository. They are identified by a hash. For example, commit 1234567.

The basic workflow is:

  1. Make changes in the working directory.
  2. Add changes to the staging area.
  3. Commit changes to the repository.
  4. Repeat.

Conceptually: working directory -> staging area -> repository.

Configuration

git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"

Create a new repository

In the directory of your project:

git init

Add files to the repository

This adds all the changes in your current directory to the …


Continue reading

Running Ollama in a Linux Environment Without Root Privileges

Posted on Thu 16 January 2025 in ollama, open-webui, AI, LLM • Tagged with ollama, open-webui, AI, LLM

Running Ollama in a Linux Environment Without Root Privileges

Running applications without root privileges is a common requirement for security and compliance reasons, especially on shared systems or in environments where users don't have administrative access. This guide will walk you through setting up ollama on a Linux system under these constraints, using some tools like uv to manage Python dependencies and configuring networking correctly. Maybe, this is not the easiest way and using Docker could be simpler, but it's a good exercise to understand how to manage Python applications without root privileges.

Prerequisites

  • A functional Python environment.
  • Basic command-line navigation skills.
  • Network access for downloading necessary files and configuring network settings.

Step-by-step Guide

1. Install uv

Firstly, we need a tool to handle Python applications efficiently without root privileges. The tool I used is uv. Here’s how you can install it:

curl -LsSf https://astral.sh/uv/install.sh | sh

This command downloads and executes the installation script for uv. After installing, verify its presence using:

which uv

You might need to restart …


Continue reading

A LaTeX makefile: latexmk

Posted on Thu 07 November 2024 in LaTeX • Tagged with LaTeX, makefile

I have been using LaTeX for a while now and I have always been annoyed by the fact that I have to run the pdflatex command multiple times to get the references and the table of contents right. Today, I colleague of mine told me about the latexmk command. It is a tool that takes care of all the dependencies and runs the necessary commands to generate the PDF file.

You can run:

latexmk -pdf yourfile.tex

And it will take care of everything. It will run pdflatex multiple times if necessary, it will run bibtex (or 'biber', as in my case) if you have a bibliography, and it will generate the PDF file.


Profiling with nvprof

Posted on Fri 19 April 2024 in Nvidia, GPU, Profiling, Jetson • Tagged with Nvidia, GPU, Profiling, Jetson

I'm working on a Jetson Nano and I want to profile my code. Nvidia provides several tools, being Nsight Compute the most powerful one. However, it cannot be run on the Jetson Nano, so I have resorted to using nvprof.

nvprof is a command-line profiler that can be used to profile CUDA applications. It is included in the CUDA Toolkit, so you should have it installed if you have CUDA installed. However, you need to be root to run it. As root, I don't have the CUDA environment set up, so I need use the full path. These are two commands that I've found useful:

/usr/local/cuda/bin/nvprof --print-gpu-trace ./my_program

This shows the GPU trace of the program. It is useful to see how the GPU is being used.

/usr/local/cuda/bin/nvprof --metrics all ./my_program

This shows all the metrics that nvprof can measure. It is useful to see how the program is using the GPU.

In addition, you can use the --log-file option to save the output to a file …


Continue reading