Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install pytorch from the source using pip

I am trying to install pytorch on a remote server. It has CentOS 6.5 and according to this link it has stopped support for CentOS 6. So, I am trying to install it via source.
The recommended method to install is by anaconda but the thing is I am getting plenty of issues while installing anaconda as it is messing with the remote server path's alot so I have decided to use pip.
But I have issues regarding converting some conda commands in pip which are as below-

conda install -c pytorch magma-cuda90
The above command is mentioned before the pytorch cloning step and it given me an error that
Could not open requirements file: [Errno 2] No such file or directory: 'pytorch'
The other issue I am facing is below-
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"} Wht should be the alternative for CMAKE_PREFIX_PATH in pip?

like image 347
Bing Avatar asked Oct 29 '19 22:10

Bing


People also ask

Can I pip install PyTorch?

Package ManagerTo install the PyTorch binaries, you will need to use one of two supported package managers: Anaconda or pip.

How do I install and import PyTorch?

To install PyTorch, you have to run the installation command of PyTorch on your command prompt. This command is available on https://pytorch.org/. Select language and cuda version as per your requirement. Now, run python -version, and Conda -version command to check Conda and python packages are installed or not.

Can I install PyTorch without CUDA?

You don't need to have cuda to install the cuda-enabled pytorch package but you need cuda to use it. We do not ship cuda with pytorch as it is a very big library.


1 Answers

According to your Python version, you can try to install from the wheel files.

pip install https://download.pytorch.org/whl/cu101/torch-1.3.0-cp36-cp36m-manylinux1_x86_64.whl   --user # For torch 
pip install https://download.pytorch.org/whl/cu101/torchvision-0.4.1-cp36-cp36m-linux_x86_64.whl  --user # For torchvision

If it fails you may want to check your glibc version:

ldd --version

because PyTorch is supported on Linux distributions that use glibc >= v2.17.

For your question:

What should be the alternative for `CMAKE_PREFIX_PATH in pip ?

CMAKE_PREFIX_PATH act as a build directive to indicate where to find modules needed for the build. In your case (installation as non-root with the --user flag) it's probably:

~/.local/lib/python3.6/site-packages

You can verify the exact location with the following command:

python -c "import site; print(site.getsitepackages()[0])"

As a side note your compilation will more likely fail if you still don't have the minimum required version of glibc.

like image 78
RMPR Avatar answered Oct 02 '22 08:10

RMPR