UV setup for computer vision using deep learning

DeepLearning
code
ComputerVision
python
linux
Author

Julien Combes

Published

April 13, 2025

UV is a drop-in replacement for pip and global python installation. I allows the management of python versions and packages. So far i only used it as a replacement for conda/venv so i only have a shallow understanding of basic feature. The build capabilities are not handled in this page yet.

What is uv

uv is a python package manager that can replace pip and the installation of python itself on any machine. Its coded in rust and is make the management of python project very fast and robust.

All the example provided in this article are assuming you run on a linux system.

it is installable with a simple line in the terminal

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

This should make the uv command available through your shell.

you can check the python versions already available by running

uv python list

if the version of python you want is not already installed you can run the next command (change the 3.14 to the required python version)

uv python install 3.14

Creation on the environment

Unlike conda, uv is based on project directories and not on global environments. So each project will have its own uv configuration. Here, you have two options.

Local quick environement

Only use a local environement that will be used only for this project. This option is good for prototyping.

In order to manage the part with GPU compatibilities, uv provides an help page to get the torch versions matching your locally installed cuda :

1uv venv --python 3.12
uv pip install torch torchvision --torch-backend=auto
2uv pip install -r requirements.txt
1
Creating the virtual environement in the current directory with the specified python version.
2
Install all packages listed in requirement.txt in the local env.
omegaconf

numpy
pandas
seaborn
matplotlib

typer

pycocotools
albumentationsX
opencv-python
torchmetrics
lightning
transformers

Complete and reproducible dev

If you want a complete reproducible management of dependencies you should use the project features of uv.

uv init --python 3.14 .
uv pip install torch torchvision --torch-backend=auto
uv add -r requirements.txt

Here, uv will create a full pyproject.toml where the python version and all the dependencies whith their versions are saved.