ralna / spral

Sparse Parallel Robust Algorithms Library
https://ralna.github.io/spral/
Other
104 stars 27 forks source link

Compile error with SPRAL GPU support #126

Closed chemrgineer closed 11 months ago

chemrgineer commented 1 year ago

Hi everyone, I'm trying to compile IPOPT with SPRAL (compiled with GPU support). As a first step I compiled hwloc with CUDA support. Then I compiled spral with these commands:

git clone https://github.com/ralna/spral
cd spral && ./autogen.sh
mkdir build && cd build
cp ../nvcc_arch_sm.c ./
CFLAGS=-fPIC CPPFLAGS=-fPIC CXXFLAGS=-fPIC FFLAGS=-fPIC FCFLAGS=-fPIC \
../configure --with-blas="-lopenblas" --with-lapack="-llapack" --with-metis="-L/usr/local/lib -lcoinmetis" --with-metis-inc-dir="-I/usr/local/include/coin-or/metis" --prefix=/home/erturk/spral
make && make test
make install

After SPRAL compilation I download and try to compile IPOPT with these commands:

git clone https://github.com/coin-or/Ipopt
cd Ipopt && mkdir build && cd build
../configure --with-spral-lflags="-L/home/erturk/spral/lib -lspral -lgfortran -lhwloc -lm -lcoinmetis -lopenblas -lstdc++ -fopenmp -lcudadevrt -lcudart -lcuda -lcublas" --with-spral-cflags="-I/home/erturk/spral/include"
make -j$(nproc --all) && make test
sudo make install

I get these errors:

/usr/bin/ld: /home/erturk/spral/lib/libspral.a(dense_factor.o): warning: relocation against `_ZN48_GLOBAL__N__16e07778_15_dense_factor_cu_8d0d865713cu_block_cholIdLj8ELj3EEEviiPKT_iPS1_iPi' in read-only section `.text'
/usr/bin/ld: /home/erturk/spral/lib/libspral.a(assemble.o): relocation R_X86_64_PC32 against symbol `_ZN44_GLOBAL__N__78fd96ee_11_assemble_cu_df8d376113cu_load_nodesEPKNS_15load_nodes_typeEPKlPKd' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status

I also opened topic in IPOPT repo. https://github.com/coin-or/Ipopt/issues/683

jfowkes commented 1 year ago

Hmm... certainly I was able to compile SPRAL no problem for GPU last time I tried it.

I assume that you're using CUDA 10 or later? I believe nvcc should support -fPIC with:

NVCCFLAGS=-Xcompiler -fPIC

as it is a compiler option rather than an nvcc option.

chemrgineer commented 1 year ago

I'm using : nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2021 NVIDIA Corporation Built on Thu_Nov_18_09:45:30_PST_2021 Cuda compilation tools, release 11.5, V11.5.119 Build cuda_11.5.r11.5/compiler.30672275_0 My graphic card driver version: 535.86.05 NVML version: 12.535.86.05