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:

It downloaded to /Download folder

In terminal:

gerardg@Nvidia:~$ cd Downloads

gerardg@Nvidia:~/Downloads$ bash

(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)

(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 -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



2.import torch


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

(If CUDA is available installation completed successfully)

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

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


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:


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.