Installing pytorch from the source using pip

I am trying to install pytorch on a remote server with CentOS 6.5.According to the pytorch, it has stopped binary support for CentOS 6 , so I am trying to install it via source. But the method they have mentioned use conda to use it but I want to install it via pip because I don’t have sudo access so there are plenty of path errors creeping up while installing via conda.
I am struck at below lines -

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?

If I’m not mistaken, the mentioned CMAKE_PREFIX_PATH makes sure to use the current conda environment, so if you are fine with a system wide installation, you could probably skip this step.
In the pytorch directory, you could run pip install -v . to install pytorch via pip.
(Note the last dot in the command! :wink: )

1 Like

Now, I am getting

CMake Error: The current CMakeCache.txt directory /tmp/pip-trgmgbq3-build/build/CMakeCache.txt is different than the directory /nethome/rxs1576/pytorch/build where CMackeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt

And Extra information - CMake is already installed in the server but I haven’t loaded it for my work.

Could you try to remove the CMakeCache.txt and try it again?

1 Like

deleting theCMakeCache.txt worked but then I got myriads of other errors which were just becoming too much overwhelming then I tried hard to install conda which worked eventually but now I am not able to install pytorch via source using conda :neutral_face::sleepy:

What error message are you getting using conda?

Below is the log after building from source-

Linking                    > /nethome/rxs1576/pytorch/build/nccl/lib/
make: *** [] Segmentation fault (core dumped)
[618/3273] Building CXX object third_party/ideep/mkl-dnn/src/CMakeFiles/mkldnn.dir/cpu/rnn/ref_rnn.cpp.o
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "", line 751, in <module>
  File "", line 310, in build_deps
  File "/nethome/rxs1576/pytorch/tools/", line 59, in build_caffe2
  File "/nethome/rxs1576/pytorch/tools/setup_helpers/", line 334, in build, my_env)
  File "/nethome/rxs1576/pytorch/tools/setup_helpers/", line 142, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "/nethome/rxs1576/anaconda3/envs/conda36/lib/python3.6/", line 311, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install', '--config', 'Release', '--', '-j', '16']' returned non-zero exit status 1.

There is also an approach which I though should work to resolve it but having issues while implementing it too(Pasting from Stack Overlfow)-
I am trying to install Pytorch in a remote server with no root privileges.
I want to install Cuda 10 on it. I have installed conda environment on it already.
Remote server has already few cuda versions like cuda9.1 and older than it.

After installing cudatoolkit:10.1.168 in the conda environment, I don’t know how to use this cuda in place of already present in the remote machine.

It use by default the already installed cuda versions by the system(9.1 in this case).

I had the same issue regarding using the python of conda which I resolved using


Is there an equivalent or any other way to use conda’s cuda?

0S-CentOS 6.5
Conda's python - 3.6.5