Using custom conda environments on UCloud
Set up your “own” conda
- Set up your own conda (instead of the default conda), following this link
- The reason is because that the system default conda is cleared every time.
- After the correct set up, you can verify by:
which conda- If it returns
/work/miniconda3/bin/conda, it’s correctly setted up.
- If it returns
Create a conda environment
The conda should be in a custom place:
conda create --prefix "/work/INFIMM Public/miniconda3/envs/scverse" python=3.12A separate conda environment for each analysis. For example, in the case below, sc_gpu is used for GPU computation of single cell analysis and scverse is used for CPU comutation of single cell analysis.
sc_gpu /work/miniconda3/envs/sc_gpu
scverse /work/miniconda3/envs/scverseMount a conda env
When submitting the job, mount the conda folder, in our case /work/INFIMM Public/miniconda3/. This path will be accessible in the application as /work/miniconda3.
(For the first time) Execute the following command
- Start the terminal interface by
conda init - Restart the terminal interface
- Activate the conda env by
conda activate "/work/INFIMM Public/miniconda3/envs/scverse" - Install
ipykernelconda install ipykernel - Add the environment as a Jupyter kernal
python -m ipykernel install --user --name cellxgene --display-name "Python (cellxgene)"
(Wrap the set up in an) Initiation script
#!/bin/bash
eval "$(/work/miniconda3/bin/conda shell.bash hook)"
conda init
conda activate scverse
python -m ipykernel install --user --name scverse --display-name "Python (scverse)"Additional infomration for creating a GPU accelerated sc analysis environment
Set up (only run once)
Use the custom conda.
eval "$(/work/miniconda3/bin/conda shell.bash hook)The conda environment should be in a custom place:
conda create --prefix /work/miniconda3/envs/sc_gpu python=3.12Activate the environment:
conda activate sc_gpuInstall PyTorch and JAX
- Identify the CUDA version (such as
12.4) bynvidia-smiornvcc --versionorcat /usr/local/cuda/version.txtordpkg -l | grep cuda
- Install the PyTorch with the appropriate command.
conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia - Install JAX
pip install -U "jax[cuda12]"
- Identify the CUDA version (such as
Install scvi
conda install scvi-tools -c conda-forgeInstall scanpy
conda install -c conda-forge scanpy python-igraph leidenalgInstall
ipykernelconda install ipykernelAdd the environment as a Jupyter kernal
python -m ipykernel install --user --name sc_gpu --display-name "Python (sc_gpu)"