If you are using OneAPI Environment, and if you are having this issue
ModuleNotFoundError: No module named 'torch'
Here are some steps, you may wish to use to troubleshoot.
Make sure you activated the oneAPI environment using below command
% source /usr/local/intel/oneapi/2021.3/setvars.sh
:: initializing oneAPI environment ...
-bash: BASH_VERSION = 4.2.46(2)-release
:: clck -- latest
:: compiler -- latest
:: dal -- latest
:: debugger -- latest
:: dev-utilities -- latest
:: inspector -- latest
:: intelpython -- latest
:: ipp -- latest
:: itac -- latest
:: LPOT -- latest
:: mkl -- latest
:: modelzoo -- latest
:: mpi -- latest
:: pytorch -- latest
:: tbb -- latest
:: tensorflow -- latest
:: oneAPI environment initialized ::
You might want to check the conda environment
% conda info --envs
# conda environments:
base * /usr/local/intel/oneapi/2021.3/intelpython/latest
% conda activate pytorch
% (pytorch-1.8.0) [user1@node1 ~]$ python
Python 3.7.10 (default, Jun 4 2021, 06:52:02)
[GCC 9.3.0] :: Intel Corporation on linux
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution
>>> import torch
If you are still having the error “ModuleNotFoundError: No module named ‘torch’ “
You may want to install directly if you have root access
% conda install pytorch torchvision cpuonly -c pytorch
If not, you may want to create a private environment similar to Creating Virtual Environment with Python using venv