torch / distro

Torch installation in a self-contained folder
BSD 3-Clause "New" or "Revised" License
555 stars 481 forks source link

Installing torch on Ubuntu 20.04? #300

Closed sorenwacker closed 3 months ago

sorenwacker commented 2 years ago

Is there recipe to install torch currently on Ubuntu 20.04?

I installed cuda from here.

And followed the instructions on torch.ch.

However, I cannot install the dependencies correctly.

>bash install-deps
E: Package 'python-software-properties' has no installation candidate

I changed this to python-software-properties to software-properties-common.

But the I get :

E: Package 'libqt4-dev' has no installation candidate
E: Package 'ipython' has no installation candidate

I changed the installation of ipython from apt-get to pip.

And added the reponinformation for qt4:

>sudo add-apt-repository ppa:rock-core/qt4

Then, I could install the dependencies.

install.sh

Before running ./install.sh. I installed the newest CMake version from github.

The install script ended with:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_cublas_device_LIBRARY (ADVANCED)
    linked by target "THC" in directory ~/torch/extra/cutorch/lib/THC

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

Error: Build error: Failed building.

Apparently that is a CUDA 10 related problem.

So, I tried the fork from nagadomi, which apparently works for CUDA 10.

.isManaged error:

This time ./install.sh resulted in:

~/torch/extra/cutorch/init.c: In function ‘cutorch_isManagedPtr’:
~/torch/extra/cutorch/init.c:938:34: error: ‘struct cudaPointerAttributes’ has no member named ‘isManaged’
  938 |     lua_pushboolean(L, attributes.isManaged);
      |                                  ^
make[2]: *** [CMakeFiles/cutorch.dir/build.make:94: CMakeFiles/cutorch.dir/init.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:142: CMakeFiles/cutorch.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Error: Build error: Failed building.

I replace.isManaged with .type == 3 as suggested here.

static int cutorch_isManagedPtr(lua_State *L)
{
  THCState *state = cutorch_getstate(L);
  if(lua_type(L, 1) != LUA_TNUMBER) {
    THError("Must receive a ptr cast as a number");
  }
  void* ptr = (void* )luaL_optinteger(L, 1, 0);
  struct cudaPointerAttributes attributes;
  cudaError_t res = cudaPointerGetAttributes(&attributes, ptr);
  if (res == cudaErrorInvalidValue) {
    lua_pushboolean(L, 0);
  } else {
    THCudaCheck(res);
    lua_pushboolean(L, attributes.type ==3 );
  }
  return 1;
}

Then

./clean.sh; ./install.sh

now returns:

...
error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
  138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
...

And I tried

CC=gcc-7 CXX=g++-7 ./install.sh

That returned the same error message. So, I downgraded to gcc 7.5.

That also did not work.

Any suggestions, how can get it to run?

cmake --version cmake version 3.22.20220103-gf940c83

nvcc --version nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2019 NVIDIA Corporation Built on Sun_Jul_28_19:07:16_PDT_2019 Cuda compilation tools, release 10.1, V10.1.243