How to create virtual environment with OpenCv and Pytorch to execute your program on GPU

This is my solution of this question.

My sequence of actions:

1.Anaconda installation:

Clicked on:

Archiconda3-0.2.3-Linux-aarch64.sh

It downloaded to /Download folder

In terminal:

gerardg@Nvidia:~$ cd Downloads

gerardg@Nvidia:~/Downloads$ bash Archiconda3-0.2.3-Linux-aarch64.sh

(I installed anaconda to create virtual environment)

  1. JetPack installation:

1.sudo apt dist-upgrade

2.sudo apt update

3.sudo apt-get install nvidia-container

4.sudo apt-get install nvidia-jetpack
(As a result i intalled jetpack 4.6.1; if you have other version of jetpack you also need other pytorch version (most likely); in this situation my sequence of actions wont work)

https://docs.nvidia.com/jetson/jetpack/install-jetpack/index.html

(Next step couldn’t be completed without JetPack)

  1. Pytorch installation:

1.conda create -n pytorch3.6 -c conda-forge python=3.6

2.conda activate pytorch3.6

3.pip install --upgrade pip

4.wget https://nvidia.box.com/shared/static/p57jwntv436lfrd78inwl7iml6p13fzh.whl -O torch-1.8.0-cp36-cp36m-linux_aarch64.whl

5 .sudo apt-get install python3-pip libopenblas-base libopenmpi-dev libomp-dev

6.sudo apt-get install libomp5 (: I installed libomp5 because I had errors, associated with requirement problems)

7.pip3 install Cython

  1. pip3 install numpy torch-1.8.0-cp36-cp36m-linux_aarch64.whl

9.pip install Pillow (Optional: I installed Pillow to work with images)

10.pip install cmake (Optional: I installed cmake because I had errors, associated with requirement problems)

  1. pip3 install numpy torch-1.8.0-cp36-cp36m-linux_aarch64.whl

12.Test:

1.python

2.import torch

3.print(torch.version)

4.print('CUDA available: ’ + str(torch.cuda.is_available()))

(If CUDA is available installation completed successfully)

  1. python3 -m pip install opencv-python==4.6.0.66 –verbose

(I installed specific version to solve problem with infinite wheels building)

Hi,

For PyTorch, please use our prebuilt that has enabled the CUDA support.

For OpenCV, please build it from the source.
Below is the script for your reference:

Thanks.