Building pytorch1.8 with cuda statically linked

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

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXE_LINKER_FLAGS="-static"

Error I am getting is this

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



  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
  CMakeFiles/cmTC_39818.dir/build

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

  Building CXX object CMakeFiles/cmTC_39818.dir/detect_cuda_version.cc.o

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

  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/detect_cuda_version.cc.o -o cmTC_39818
  -Wl,-rpath,/usr/local/cuda/lib64 /usr/local/cuda/lib64/libcudart.so

  /usr/bin/ld: attempted static link of dynamic object
  `/usr/local/cuda/lib64/libcudart.so'

  collect2: error: ld returned 1 exit status

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

  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!