Yes, it is best practice not to use pip in your main account, but to use versioning (as Cody mentioned).
pip -v list | egrep -v “/usr/lib/python3/dist-packages”
* This will show all packages that are in your current environment not from Lambda.
It is best to use:
- Docker
- Python venv
- Anaconda/Miniconda
This will allow you to have a environment for each code, so it does not conflict with others.
- Docker images should be complete or at least reset to defaults on relaunching the image.
NVIDIA NGC Tutorial: Run a PyTorch Docker Container using nvidia-container-toolkit on Ubuntu
- Python venv - allows you to try with using system installed packages or without
- This will setup a environment using system packages by default and you just add pip packages to see if they are compatible. Of course you may want to make the environment names much shorter, but for clarity I made them longer (these are affected by default pip installs in ~/.local or /usr/local):
$ python -m venv --system-site-packages myenv-with-site-packages
$ source ./myenv-site-packages/bin/activate
- This will setup a independent environment, needed at times when libraries conflict
$ python -m venv myenv-independent/bin/activate
$ source ./myenv-independent
- Anaconda always always replaces any except software in /usr/local or ~/.local
- To setup conda you need to down load their script install, then for example with CUDA 11.8:
$ conda create --name torch_gpu pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
$ conda activate torch_gpu
Pytorch has a nice matrix on how to install (limited versions but helpful):
Start Locally | PyTorch
pip is limited on what it can install, and at times you need to change the LD_LIBRARY_PATH for pip packages (in Conda or in python venv). And always make sure your ~/.local and /usr/local do not have conflicts.
Also make sure ‘which python’ you are using. Example:
$ which python
/usr/bin/python
Versus
$ which python
/home/username/miniconda3/bin/python
I have additional examples and they break between versions and changes in packages.
https://github.com/markwdalton/lambdalabs/tree/main/documentation/software
Also a useful tip to find alternate versions without any work is use the “?” versus version and it will show you valid versions that are available.
$ pip install tensorflow-gpu==?
ERROR: Could not find a version that satisfies the requirement tensorflow-gpu==? (from versions: 2.8.0rc0, 2.8.0rc1, 2.8.0, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.9.0rc0, 2.9.0rc1, 2.9.0rc2, 2.9.0, 2.9.1, 2.9.2, 2.9.3, 2.10.0rc0, 2.10.0rc1, 2.10.0rc2, 2.10.0rc3, 2.10.0, 2.10.1, 2.11.0rc0, 2.11.0rc1, 2.11.0rc2, 2.11.0, 2.12.0)
ERROR: No matching distribution found for tensorflow-gpu==?