lua, torch install & troubleshooting - sogang-nlp-paper/WNGT-2019-DGT-NLG-Track GitHub Wiki
Requirements
- Download Lua from the official website and build.
curl -R -O http://www.lua.org/ftp/lua-5.3.5.tar.gz
tar zxf lua-5.3.5.tar.gz
cd lua-5.3.5
make linux test
sudo make install
- Download torch from the official website and install.
git clone https://github.com/torch/distro.git ~/torch --recursive
cd ~/torch; bash install-deps;
./install.sh
Trouble shooting
Torch ์ค์น
./install.sh
๋ก torch ์ค์น์ ์๋์ ๊ฐ์ ์๋ฌ๊ฐ ๋ฌ๋ค.
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 /home/hwijeen/Downloads/distro/extra/cutorch/lib/THC
CuBLAS๋ basic linear algebra๋ฅผ ๋ด๋นํ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ธ๋ฐ, CUDA 10.1๋ถํฐ๋ ๋น ์ ธ์๋ค.
์๋ฒ์ CUDA 10.0์ ์ค์นํ๊ณ PATH, LD_LIBRARY_PATH๋ฅผ ์ก์์คฌ๋ค.
์ดํ์ ./install.sh
์ ๋ค์ ํ๋๋ฐ ๊ฐ์ ์๋ฌ๊ฐ ๋ฌ๊ณ , ์๋ฌ ๋ฉ์์ง์ -- got cuda version 10.1
๊ฐ ์์๋ค.
์ด๋ ๊ฒฝ๋ก๋ก CUDA 10.1์ด ์กํ๋ ๊ฑด์ง ๋ชจ๋ฅด๊ฒ ์ด์ ์๋ฒ์์ ์์ CUDA 10.1์ ์ง์๋ฒ๋ ธ๋ค. apt๋ฅผ ์ด์ฉํ ์ ๊ฑฐ ํ /usr/local
์ ์๋ ๊ฑฐ๊น์ง ์ง์ ์ง์ ๋ค.
apt --installed list | grep cuda # ํ์ธ
sudo apt-get --purge remove cuda-10.1
sudo apt-get --purge remove cuda-toolkit-10-1
suro rm -rf /usr/local/cuda-10.1
(์ฌ๊ธฐ์๋ถํฐ ๋ก์ปฌ์ ํฌ๊ธฐํ๊ณ Docker๋ก ๋์ด์ด) ์๋ฌ๋ ์๋์ ๊ฐ์๋๋ฐ, gcc ๋ฒ์ ๋ฌธ์ ์๋ค. Github issue ์กฐ์ธ์ ๋ฐ๋ผ gcc version์ 4.9๋ก ๋ฐ๊ฟ์คฌ๋ค.
jopts=$(getconf _NPROCESSORS_CONF) # ์ค๋ฅ ๋ฉ์์ง ์ค ์ผ๋ถ
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9 g++-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9
๊ทธ๋ฌ๋ gcc4.9๋ฒ์ ์ ๋ฐ๊ฟ์ฃผ๋ ์๋ฌ. ๊ฒ์ํด๋ณด๋ gfortran๊ณผ ๋ฒ์ ์ด ๋ฌ๋ผ์ ธ์ ์ค๋ฅ๊ฐ ๋๋จ๋ค
/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status
Makefile:157: recipe for target '../libopenblas_haswellp-r0.3.7.dev.so' failed
make[1]: Leaving directory '/tmp/tmp.KmVvu8PjfI/OpenBLAS/exports'
make[1]: *** [../libopenblas_haswellp-r0.3.7.dev.so] Error 1
make: *** [shared] Error 2
Makefile:101: recipe for target 'shared' failed
Error. OpenBLAS could not be compiled
๊ทธ๋์ gfortran-4.9 ์ค์นํด์ฃผ๊ณ uptate-alternatives ์ฌ์ฉํด์ ๊ธฐ๋ณธ gfortran์ผ๋ก ์ก์์ฃผ๊ธฐ
sudo apt-get update
sudo apt-get install gfortran-4.9
sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-4.9
์ฌ๊ธฐ์ ๋์จ cutorh ๊ด๋ จ ์๋ฌ๋ ๊ผญ ์ก์์ฃผ์
export TORCH_NVCC_FLAGS="-D__CUDA_NO_HALF_OPERATORS__"
cutorch๋ง ๋ฐ๋ก ์ค์น์๋
luarocks๋ฅผ ํตํด cutorch ํจํค์ง๋ฅผ ์ค์นํ๋ ค๋ ์๋์ ๊ฐ์ ์ค๋ฅ๊ฐ ๋ฌ๋ค
luarocks install cutorch # ์ค์น
CMake Error at /home/hwijeen/Downloads/distro/install/share/cmake/torch/FindCUDA.cmake:643 (message):
Specify CUDA_TOOLKIT_ROOT_DIR
Stackoverflow๋ต๋ณ์ ๋ฐ๋ผ cmake CUDA_TOOLKIT_ROOT_DIR์ ์ง์ ์ก์์คฌ๋ค.
cmake -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda # torch๊ฐ ์ค์น๋ ๋๋ ํ ๋ฆฌ์์