Install Miniconda3 on nvidia/cuda Docker

Q

How to install Miniconda3 on nvidia/cuda Docker?

✍: FYIcenter.com

A

If you want to run Miniconda3 to manage different versions of Python applications, you can follow this tutorial to install it on the nvidia/cuda Docker.

1. Start nvidia/cuda Docker and let it run for a long time, so we can attach a terminal to it at any time.

fyicenter# docker run --name my_cuda --detach nvidia/cuda:11.0-base sleep 36000000
  time="2021-08-14T14:23:39.780948393+08:00" level=info msg="starting signal loop" 
  namespace=moby path=/run/docker/containerd/daemon/io.containerd.runtime.v2.task/moby/... pid=3149485

fyicenter# docker ps
CONTAINER ID   IMAGE                   COMMAND            STATUS          NAMES
e4395c83ac54   nvidia/cuda:11.0-base   "sleep 36000000"   Up 10 seconds   my_cuda

2. Attach a terminal to the running docker.

fyicenter# docker exec -it my_cuda /bin/bash 

root@e4395c83ac54:/# 

3. Install "wget", so we can download other packages.

root@e4395c83ac54:/# apt-get update
  Get:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
  ...

root@e4395c83ac54:/# apt-get install -y wget
  The following additional packages will be installed:
    libpsl5 publicsuffix
  The following NEW packages will be installed:
    libpsl5 publicsuffix wget
   ...

4. Download and install Miniconda3.

root@e4395c83ac54:/# wget -q -P /tmp \
  https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

root@e4395c83ac54:/# bash /tmp/Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda
  PREFIX=/opt/conda
  Unpacking payload ...
  Collecting package metadata (current_repodata.json): done                                                                           
  Solving environment: done

  ## Package Plan ##
    environment location: /opt/conda
    added / updated specs:
      - _libgcc_mutex==0.1=main
      - _openmp_mutex==4.5=1_gnu

  ...

5. Update Conda environment.

root@e4395c83ac54:/# PATH="/opt/conda/bin:$PATH"

root@e4395c83ac54:/# conda update -qy conda
  Collecting package metadata (current_repodata.json): ...working... done
  Solving environment: ...working... done

  ## Package Plan ##
    environment location: /opt/conda
    added / updated specs:
      - conda
  ...

6. Initialize Conda environment.

root@e4395c83ac54:/# conda init
  ...
  modified      /root/.bashrc
  ==> For changes to take effect, close and re-open your current shell.

7. Logout and login again. You see the Conda "base" environment prompt.

root@e4395c83ac54:/# exit 
exit

fyicenter# docker exec -it my_cuda /bin/bash 

(base) root@e4395c83ac54:/# 

8. Get out Conda and get in again.

(base) root@e4395c83ac54:/# conda deactivate
root@e4395c83ac54:/# 

root@e4395c83ac54:/# conda activate  
(base) root@e4395c83ac54:/# 

 

Upgrade/Downgrade Python in Conda on nvidia/cuda Docker

"docker pull nvidia/cuda" - Download Docker Image

NVIDIA GPU Server Docker Image

⇑⇑ Docker Container Platform - Tutorials

2023-03-07, 755🔥, 0💬