Compiling on Linux
MathieuMoalic opened this issue · 2 comments
MathieuMoalic commented
Hi,
I'm trying to compile Boris on linux. For my sanity and the sake of reproducibility and portability, I'm using docker to compile with the following Dockerfile:
FROM nvidia/cuda:12.0.1-devel-ubuntu20.04
RUN DEBIAN_FRONTEND=noninteractive apt update && \
apt-get -qq install \
wget \
build-essential \
libomp-dev \
libtbb-dev \
python-dev \
git
RUN wget https://www.fftw.org/fftw-3.3.10.tar.gz && \
tar -xf fftw-3.3.10.tar.gz && \
cd fftw-3.3.10 && \
./configure && \
make && \
make install
RUN git clone https://github.com/SerbanL/Boris2 /src
CMD cd /src && \
make configure arch=80 sprec=1 python=3.8 cuda=12.0 && \
make compile -j 16
make install
I run with docker build -t boris . && docker run -it --rm --gpus all --name borisc boris
. I get the following result :
mkdir -p Boris/Boris_o
mkdir -p Boris/Boris_cuo
Configured for -arch=sm_80 and SINGLEPRECISION = 1. Python version 3.8. CUDA Toolkit version 12.0.
g++ -I/usr/local/cuda-12.0/targets/x86_64-linux/include/ -c -Ofast -std=c++17 -I/usr/include/python3.8/ -IBorisLib -IBorisCUDALib -fopenmp Boris/SMElastic.cpp -o Boris/Boris_o/SMElastic.o
g++ -I/usr/local/cuda-12.0/targets/x86_64-linux/include/ -c -Ofast -std=c++17 -I/usr/include/python3.8/ -IBorisLib -IBorisCUDALib -fopenmp Boris/DiffEq_Iterate.cpp -o Boris/Boris_o/DiffEq_Iterate.o
g++ -I/usr/local/cuda-12.0/targets/x86_64-linux/include/ -c -Ofast -std=c++17 -I/usr/include/python3.8/ -IBorisLib -IBorisCUDALib -fopenmp Boris/TMRCUDA.cpp -o Boris/Boris_o/TMRCUDA.o
g++ -I/usr/local/cuda-12.0/targets/x86_64-linux/include/ -c -Ofast -std=c++17 -I/usr/include/python3.8/ -IBorisLib -IBorisCUDALib -fopenmp Boris/STransportCUDA.cpp -o Boris/Boris_o/STransportCUDA.o
g++ -I/usr/local/cuda-12.0/targets/x86_64-linux/include/ -c -Ofast -std=c++17 -I/usr/include/python3.8/ -IBorisLib -IBorisCUDALib -fopenmp Boris/DipoleDipoleTFunc_Self.cpp -o Boris/Boris_o/DipoleDipoleTFunc_Self.o
g++ -I/usr/local/cuda-12.0/targets/x86_64-linux/include/ -c -Ofast -std=c++17 -I/usr/include/python3.8/ -IBorisLib -IBorisCUDALib -fopenmp Boris/DemagTFunc_L.cpp -o Boris/Boris_o/DemagTFunc_L.o
g++ -I/usr/local/cuda-12.0/targets/x86_64-linux/include/ -c -Ofast -std=c++17 -I/usr/include/python3.8/ -IBorisLib -IBorisCUDALib -fopenmp Boris/Atom_Demag_N.cpp -o Boris/Boris_o/Atom_Demag_N.o
g++ -I/usr/local/cuda-12.0/targets/x86_64-linux/include/ -c -Ofast -std=c++17 -I/usr/include/python3.8/ -IBorisLib -IBorisCUDALib -fopenmp Boris/DiffEqAFMCUDA.cpp -o Boris/Boris_o/DiffEqAFMCUDA.o
g++ -I/usr/local/cuda-12.0/targets/x86_64-linux/include/ -c -Ofast -std=c++17 -I/usr/include/python3.8/ -IBorisLib -IBorisCUDALib -fopenmp Boris/DWRunTimeFit.cpp -o Boris/Boris_o/DWRunTimeFit.o
g++ -I/usr/local/cuda-12.0/targets/x86_64-linux/include/ -c -Ofast -std=c++17 -I/usr/include/python3.8/ -IBorisLib -IBorisCUDALib -fopenmp Boris/DiffEqFMCUDA.cpp -o Boris/Boris_o/DiffEqFMCUDA.o
g++ -I/usr/local/cuda-12.0/targets/x86_64-linux/include/ -c -Ofast -std=c++17 -I/usr/include/python3.8/ -IBorisLib -IBorisCUDALib -fopenmp Boris/ModulesCUDA.cpp -o Boris/Boris_o/ModulesCUDA.o
g++ -I/usr/local/cuda-12.0/targets/x86_64-linux/include/ -c -Ofast -std=c++17 -I/usr/include/python3.8/ -IBorisLib -IBorisCUDALib -fopenmp Boris/SimFiles.cpp -o Boris/Boris_o/SimFiles.o
g++ -I/usr/local/cuda-12.0/targets/x86_64-linux/include/ -c -Ofast -std=c++17 -I/usr/include/python3.8/ -IBorisLib -IBorisCUDALib -fopenmp Boris/SurfExchange.cpp -o Boris/Boris_o/SurfExchange.o
g++ -I/usr/local/cuda-12.0/targets/x86_64-linux/include/ -c -Ofast -std=c++17 -I/usr/include/python3.8/ -IBorisLib -IBorisCUDALib -fopenmp Boris/DiffEqFM_Evals_RK4.cpp -o Boris/Boris_o/DiffEqFM_Evals_RK4.o
g++ -I/usr/local/cuda-12.0/targets/x86_64-linux/include/ -c -Ofast -std=c++17 -I/usr/include/python3.8/ -IBorisLib -IBorisCUDALib -fopenmp Boris/Demag.cpp -o Boris/Boris_o/Demag.o
g++ -I/usr/local/cuda-12.0/targets/x86_64-linux/include/ -c -Ofast -std=c++17 -I/usr/include/python3.8/ -IBorisLib -IBorisCUDALib -fopenmp Boris/STransport_Charge.cpp -o Boris/Boris_o/STransport_Charge.o
In file included from BorisLib/BLib_Funcs.h:10,
from BorisLib/BorisLib.h:15,
from Boris/Simulation.h:36,
from Boris/SimFiles.cpp:2:
BorisLib/Funcs_Files_Linux.h:11:10: fatal error: X11/Xlib.h: No such file or directory
11 | #include <X11/Xlib.h>
| ^~~~~~~~~~~~
compilation terminated.
In file included from BorisLib/BLib_Funcs.h:10,
from BorisLib/BorisLib.h:15,
from Boris/SMElastic.h:3,
from Boris/SMElastic.cpp:2:
BorisLib/Funcs_Files_Linux.h:11:10: fatal error: X11/Xlib.h: No such file or directory
11 | #include <X11/Xlib.h>
| ^~~~~~~~~~~~
compilation terminated.
In file included from BorisLib/BLib_Funcs.h:10,
from BorisLib/BorisLib.h:15,
from Boris/DiffEq.h:3,
from Boris/DiffEq_Iterate.cpp:2:
BorisLib/Funcs_Files_Linux.h:11:10: fatal error: X11/Xlib.h: No such file or directory
11 | #include <X11/Xlib.h>
| ^~~~~~~~~~~~
compilation terminated.
In file included from BorisLib/BLib_Funcs.h:10,
from BorisLib/BorisLib.h:15,
from Boris/DipoleDipoleTFunc.h:3,
from Boris/DipoleDipoleTFunc_Self.cpp:2:
BorisLib/Funcs_Files_Linux.h:11:10: fatal error: X11/Xlib.h: No such file or directory
11 | #include <X11/Xlib.h>
| ^~~~~~~~~~~~
compilation terminated.
In file included from BorisLib/BLib_Funcs.h:10,
from BorisLib/BorisLib.h:15,
from Boris/DemagTFunc.h:3,
from Boris/DemagTFunc_L.cpp:2:
BorisLib/Funcs_Files_Linux.h:11:10: fatal error: X11/Xlib.h: No such file or directory
11 | #include <X11/Xlib.h>
| ^~~~~~~~~~~~
In file included from BorisLib/BLib_Funcs.h:10,
from BorisLib/BorisLib.h:15,
from Boris/STransport.h:3,
from Boris/STransport_Charge.cpp:2:
BorisLib/Funcs_Files_Linux.h:11:10: fatal error: X11/Xlib.h: No such file or directory
11 | #include <X11/Xlib.h>
| ^~~~~~~~~~~~
compilation terminated.
compilation terminated.
In file included from BorisLib/BLib_Funcs.h:10,
from BorisLib/BorisLib.h:15,
from Boris/DWRunTimeFit.h:5,
from Boris/DWRunTimeFit.cpp:2:
BorisLib/Funcs_Files_Linux.h:11:10: fatal error: X11/Xlib.h: No such file or directory
11 | #include <X11/Xlib.h>
| ^~~~~~~~~~~~
compilation terminated.
make: *** [makefile:78: Boris/Boris_o/SimFiles.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [makefile:78: Boris/Boris_o/SMElastic.o] Error 1
In file included from BorisLib/BLib_Funcs.h:10,
from BorisLib/BorisLib.h:15,
from Boris/Atom_Demag_N.h:3,
from Boris/Atom_Demag_N.cpp:2:
BorisLib/Funcs_Files_Linux.h:11:10: fatal error: X11/Xlib.h: No such file or directory
11 | #include <X11/Xlib.h>
| ^~~~~~~~~~~~
make: *** [makefile:78: Boris/Boris_o/DiffEq_Iterate.o] Error 1
compilation terminated.
make: *** [makefile:78: Boris/Boris_o/DemagTFunc_L.o] Error 1
make: *** [makefile:78: Boris/Boris_o/STransport_Charge.o] Error 1
make: *** [makefile:78: Boris/Boris_o/DipoleDipoleTFunc_Self.o] Error 1
make: *** [makefile:78: Boris/Boris_o/DWRunTimeFit.o] Error 1
make: *** [makefile:78: Boris/Boris_o/Atom_Demag_N.o] Error 1
In file included from BorisLib/BLib_Funcs.h:10,
from BorisLib/BorisLib.h:15,
from Boris/DiffEq.h:3,
from Boris/DiffEqFM.h:3,
from Boris/DiffEqFM_Evals_RK4.cpp:2:
BorisLib/Funcs_Files_Linux.h:11:10: fatal error: X11/Xlib.h: No such file or directory
11 | #include <X11/Xlib.h>
| ^~~~~~~~~~~~
compilation terminated.
make: *** [makefile:78: Boris/Boris_o/DiffEqFM_Evals_RK4.o] Error 1
In file included from BorisLib/BLib_Funcs.h:10,
from BorisLib/BorisLib.h:15,
from Boris/Demag.h:3,
from Boris/Demag.cpp:2:
BorisLib/Funcs_Files_Linux.h:11:10: fatal error: X11/Xlib.h: No such file or directory
11 | #include <X11/Xlib.h>
| ^~~~~~~~~~~~
compilation terminated.
make: *** [makefile:78: Boris/Boris_o/Demag.o] Error 1
In file included from BorisLib/BLib_Funcs.h:10,
from BorisLib/BorisLib.h:15,
from Boris/SurfExchange.h:3,
from Boris/SurfExchange.cpp:2:
BorisLib/Funcs_Files_Linux.h:11:10: fatal error: X11/Xlib.h: No such file or directory
11 | #include <X11/Xlib.h>
| ^~~~~~~~~~~~
compilation terminated.
make: *** [makefile:78: Boris/Boris_o/SurfExchange.o] Error 1
In file included from BorisLib/BLib_Funcs.h:10,
from BorisLib/BorisLib.h:15,
from Boris/TMR.h:3,
from Boris/TMRCUDA.cpp:8:
BorisLib/Funcs_Files_Linux.h:11:10: fatal error: X11/Xlib.h: No such file or directory
11 | #include <X11/Xlib.h>
| ^~~~~~~~~~~~
compilation terminated.
In file included from BorisLib/BLib_Funcs.h:10,
from BorisLib/BorisLib.h:15,
from Boris/STransport.h:3,
from Boris/STransportCUDA.cpp:8:
BorisLib/Funcs_Files_Linux.h:11:10: fatal error: X11/Xlib.h: No such file or directory
11 | #include <X11/Xlib.h>
| ^~~~~~~~~~~~
compilation terminated.
make: *** [makefile:78: Boris/Boris_o/TMRCUDA.o] Error 1
make: *** [makefile:78: Boris/Boris_o/STransportCUDA.o] Error 1
In file included from BorisLib/BLib_Funcs.h:10,
from BorisLib/BorisLib.h:15,
from Boris/DiffEq.h:3,
from Boris/DiffEqFM.h:3,
from Boris/DiffEqFMCUDA.cpp:7:
BorisLib/Funcs_Files_Linux.h:11:10: fatal error: X11/Xlib.h: No such file or directory
11 | #include <X11/Xlib.h>
| ^~~~~~~~~~~~
compilation terminated.
make: *** [makefile:78: Boris/Boris_o/DiffEqFMCUDA.o] Error 1
In file included from BorisLib/BLib_Funcs.h:10,
from BorisLib/BorisLib.h:15,
from Boris/DiffEq.h:3,
from Boris/DiffEqAFM.h:3,
from Boris/DiffEqAFMCUDA.cpp:7:
BorisLib/Funcs_Files_Linux.h:11:10: fatal error: X11/Xlib.h: No such file or directory
11 | #include <X11/Xlib.h>
| ^~~~~~~~~~~~
compilation terminated.
make: *** [makefile:78: Boris/Boris_o/DiffEqAFMCUDA.o] Error 1
I tried installing xorg
but it doesn't change a thing.
SerbanL commented
Hi Mathieu,
First, try to find if X11 is on your system: "find /usr/include/X11 -name Xlib.h"
If, not then install it: "sudo apt-get install libx11-dev"
Let me know if it works.
Serban
MathieuMoalic commented
This worked. Other changes I had to make:
- python-dev -> python3.9-dev ( I think it's python2 if you don't specify the version)
g++ $(OBJ_DIR)/*.o $(CUOBJ_DIR)/*.o -fopenmp -lpython$(python) -ltbb -lfftw3 -lX11 -L/usr/local/cuda-$(cuda)/targets/x86_64-linux/lib/ -lcudart -lcufft -lcudadevrt -o BorisLin
->-o BorisLin2
because 'BorisLin' already exists and is a directory.
Here is a working Dockerfile:
FROM nvidia/cuda:12.0.1-devel-ubuntu20.04
RUN apt update && \
DEBIAN_FRONTEND=noninteractive apt-get -qq install \
wget \
build-essential \
libomp-dev \
libtbb-dev \
libx11-dev \
python3.9-dev \
git
RUN wget https://www.fftw.org/fftw-3.3.10.tar.gz && \
tar -xf fftw-3.3.10.tar.gz && \
cd fftw-3.3.10 && \
./configure && \
make && \
make install
RUN git clone https://github.com/SerbanL/Boris2 /src
CMD cd /src && \
make configure arch=80 sprec=1 python=3.9 cuda=12.0 && \
make compile -j 16 && \
make install