Install Tensorflow2 or PyTorch with conda

Create a conda environment

  1. If not already installed, download and install conda (anaconda)
  2. If not done, finalize conda installation and configuration (adjust the string of PATH_TO_CONDA)
    1. $ source PATH_TO_CONDA/anaconda3/bin/activate
    2. $ conda init
  3. Download TF2.10-cuda.yml (older version : TF2.6-cuda.yml )
  4. Create the conda environment with the yml file you want (this example will create it in /tmp)
    1. $ conda env create --prefix /tmp/${USER}/conda_TF2.10-cuda -f TF2.10-cuda.yml
  5. Activate the environment $ conda activate /tmp/${USER}/conda_TF2.6-cuda
  6. You can now enjoy your virtual environment ! (The previous .yml file is for linux without the bug of the ‘Cannot register 2 metrics with the same name: /tensorflow/api/keras/optimizers’ that is linked with a keras/tensorflow versions (2.7 vs 2.6); For windows, remove the cupti package)
  7. When you want to stop, you can deactivate an environment to restore initial one (base) : $ conda deactivate

A short summary of conda utilization:

This procedure is the same for PyTorch, just download pytorch1.12-cuda.yml and adapt the previous lines.

$ conda env create --prefix /tmp/${USER}/pytorch1.12-cuda -f pytorch1.12-cuda.yml


by

Tags: