Install Conda Client

We recommend using the Mambaforge installer to setup conda client for its fast dependency resolution capability. Modify the value of INSTALL_PREFIX in the code snippet below to the desired installation prefix then execute in your shell.

Note: Make sure to use sudo if installing conda client into root managed directory.

INSTALL_PREFIX='.'
CONDA_INSTALLER_URL='https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh'
CONDA_INSTALLER=mambaforge.sh
wget ${CONDA_INSTALLER_URL} -O ${CONDA_INSTALLER}
bash ${CONDA_INSTALLER} -b -p ${INSTALL_PREFIX}
rm ${CONDA_INSTALLER}
${INSTALL_PREFIX}/conda/bin/conda init

(Optional) Configure Default Channels for Conda

If you setup your conda client using the Mambaforge installer, then you can stop reading this section now.

AWS distribution of PyTorch packages are built against dependencies from conda-forge. To ensure compatibility, we recommend user to set conda-forge channels as default_channels. You can run below command to set conda-forge channels as default_channels.

tee $HOME/.condarc <<EOF
default_channels:
 - conda-forge
EOF

You can verify above configuration by running conda info and you show see output similar to below.

     active environment : base
    active env location : /home/ec2-user/conda
            shell level : 1
       user config file : /home/ec2-user/.condarc
 populated config files : /home/ec2-user/.condarc
          conda version : 22.11.1
    conda-build version : 3.23.3
         python version : 3.10.9.final.0
       virtual packages : __archspec=1=x86_64
                          __cuda=11.7=0
                          __glibc=2.26=0
                          __linux=5.4.228=0
                          __unix=0=0
       base environment : /home/ec2-user/conda  (writable)
      conda av data dir : /home/ec2-user/conda/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /home/ec2-user/conda/pkgs
                          /home/ec2-user/.conda/pkgs
       envs directories : /home/ec2-user/conda/envs
                          /home/ec2-user/.conda/envs
               platform : linux-64
...         

(Optional) Create a conda environment

You can create a conda environment by either utilizing an environment.yaml file or using a command. We recommend maintaining your conda environment using the environment.yaml approach, to learn more about this approach, see documentation.

To create a conda environment using environment yaml file, create a file called environment.yaml with the following content:

name: myenv
channels:
  - conda-forge
dependencies:
  - python=3.10

Then, create the environment using:

conda env create -f environment.yml 

To create a conda environment using a command:

conda create -n myenv python=3.10