Building pytorch1.8 with cuda statically linked

I was running this command in docker for building pytorch with source code.


Error I am getting is this

CMake Error at cmake/public/cuda.cmake:74 (message):
  Caffe2: Couldn't determine version from header: Change Dir:

  Run Build Command(s): /opt/conda/bin/cmake -E env VERBOSE=1 /usr/bin/make
  -f Makefile cmTC_39818/fast

  /usr/bin/make -f CMakeFiles/cmTC_39818.dir/build.make

  make[1]: Entering directory '/pytorch/CMakeFiles/CMakeTmp'

  Building CXX object CMakeFiles/cmTC_39818.dir/

  /usr/bin/c++ -I/usr/local/cuda/include -Wno-deprecated
  -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -o
  CMakeFiles/cmTC_39818.dir/ -c

  Linking CXX executable cmTC_39818

  /opt/conda/bin/cmake -E cmake_link_script
  CMakeFiles/cmTC_39818.dir/link.txt --verbose=1

  /usr/bin/c++ -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL
  -fopenmp -static -rdynamic
  CMakeFiles/cmTC_39818.dir/ -o cmTC_39818
  -Wl,-rpath,/usr/local/cuda/lib64 /usr/local/cuda/lib64/

  /usr/bin/ld: attempted static link of dynamic object

  collect2: error: ld returned 1 exit status

  CMakeFiles/cmTC_39818.dir/build.make:99: recipe for target 'cmTC_39818'

  make[1]: *** [cmTC_39818] Error 1

  make[1]: Leaving directory '/pytorch/CMakeFiles/CMakeTmp'

  Makefile:127: recipe for target 'cmTC_39818/fast' failed

  make: *** [cmTC_39818/fast] Error 2

Call Stack (most recent call first):
  cmake/Dependencies.cmake:1148 (include)
  CMakeLists.txt:564 (include)

-- Configuring incomplete, errors occurred!