stochasticHydroTools / SlenderBody

Slender-body hydrodynamics
11 stars 4 forks source link

Compilation Error #6

Closed Nasrollah closed 1 year ago

Nasrollah commented 1 year ago

Dear developers,

I have tried to successfully compiled "SlenderBody" source code on a cluster and the output was attached in here. However, when I try to run an example using this command"python3 ThreeShearedFibs.py". I got this error: " (SlenderBody) [scnhv@login1.arc4 SlenderBody]$ cd Python/ (SlenderBody) [scnhv@login1.arc4 Python]$ cd Examples/ (SlenderBody) [scnhv@login1.arc4 Examples]$ python3 ThreeShearedFibs.py Traceback (most recent call last): File "/home/home01/scnhv/SlenderBody/Python/Examples/ThreeShearedFibs.py", line 1, in from fiberCollection import fiberCollection ModuleNotFoundError: No module named 'fiberCollection' (SlenderBody) [scnhv@login1.arc4 Examples]$ ".

I am not sure whether or not there is any problem related to compilation or something else. I would be wondering if you could guide me on this issue. [Compilation_SlenderBody.txt](https://github.com/stochasticHydroTools/SlenderBody/files/12099508/Compilation_SlenderBody.txt)

Yours sincerely, Nasrollah Hajaliakbari.

omaxian commented 1 year ago

Hi Nasrollah,

It looks like you were able to compile everything successfully. Since fiberCollection is a python module, the error you are getting is because your computer cannot find that module. You need to add whatever folder it is in to your python path. This post: https://stackoverflow.com/questions/3402168/permanently-add-a-directory-to-pythonpath talks about how to do that.

OM

Nasrollah commented 1 year ago

Dear Dr. Ondrej Maxian,

Thanks for your response. I successfully added my folder into my python path based on the post. Now, I have faced a new problem like this: " (SlenderBody) [scnhv@login1.arc4 Examples]$ python3 ThreeShearedFibs.py Traceback (most recent call last): File "/home/home01/scnhv/SlenderBody/Python/Examples/ThreeShearedFibs.py", line 3, in from fiberCollection import fiberCollection File "/home/home01/scnhv/SlenderBody/Python/fiberCollection.py", line 4, in from FiberCollectionC import FiberCollectionC ImportError: /home/home01/scnhv/SlenderBody/Python/cppmodules/FiberCollectionC.so: undefined symbol: LAPACKE_dgesvd (SlenderBody) [scnhv@login1.arc4 Examples]$ ". This problem is related to this line of source code: https://github.com/stochasticHydroTools/SlenderBody/blob/1bce536bee55482819a15ac756137028ddeebe5b/Python/cppmodules/VectorMethods.cpp#L125 I have attached the makefile for the directory used for compilation (UAMMD_PSE_Python) which I think is related to this error Makefile.txt

I would be wondering if you could kindly help me solve this issue as well.

Best regards, Nasrollah Hajaliakbari

omaxian commented 1 year ago

Nasrollah,

The error you are getting means that when you compile the folder "cppmodules," (which is where FiberCollectionC.cpp is), you are not correctly linking the LAPACKE library. The makefile that is in there has this command: LDLIBS=-llapacke to link the libraries. You need to (1) make sure you have LAPACKE and CBLAS installed on your cluster, and (2) you might need to tell the compiler where to find those libraries by changing that line in the makefile to LDLIBS=-I/usr/include/lapacke -llapacke or wherever LAPACKE is installed for you. Ditto for the other libraries.

Ondrej Maxian

Nasrollah commented 1 year ago

Dear Dr. Ondrej Maxian,

Thanks for your respone. In fact, I did not have any LAPACKE and CBLAS installed on the cluster and therefore, I was forced to compile it using the source code from link below and unfortunately, it was not realized it by SlenderBody: https://github.com/xianyi/OpenBLAS I only have intel mkl 2019.0 library on the cluster . I would be wondering if you could guide me which version of LAPACKE and CBLAS are compatible with your source code that I need to install on cluster and which flags must be on while compiling and how to link them with intel mkl library.

Best regards, Nasrollah Hajaliakbari

RaulPPelaez commented 1 year ago

MKL is interchangeable with Lapack/Cblas by changing the compiler options. This utility will help you with the exact flags for your system: https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html As far as I can see your Makefile is in the right direction. Change = -I/home/home01/scnhv/.conda/envs/SlenderBody/bin/include by -I$CONDA_PREFIX/include. Uncomment the -DUSE_MKL option.

omaxian commented 1 year ago

Nasrollah,

It is actually easier to compile some of the code using Intel. In addition to what Raul notes above (which refers to the makefile in UAMMD), there is another makefile in the folder cppmodules that you can modify to use Intel. In particular modify this line to simply say LDLIBS=-mkl In addition, as you pointed out, there is an issue in VectorMethods.cpp. If you look at the code here, you need to comment lines 3 and 4 and uncomment line 18. Then it should compile without issue.

OM

Nasrollah commented 1 year ago

Dear Dr. Raul P Pelaez and Ondrej Maxian

Thanks for providing the solutions for compilation. I have done whatever you have recommended and I recompiled the source code and I got this error:

(SlenderBody) [scnhv@login2.arc4 SlenderBody]$ bash install.sh -DUAMMD_DEBUG -g -G
make: Entering directory `/home/home01/scnhv/SlenderBody/Python'
cd Dependencies/UAMMD_PSE_Python && make
make[1]: Entering directory `/home/home01/scnhv/SlenderBody/Python/Dependencies/UAMMD_PSE_Python'
/apps/developers/compilers/cuda/12.0.1/1/default/bin/nvcc -ccbin=/apps/developers/compilers/gnu/8.3.0/1/default/bin/g++                            -w -std=c++14 -DMAXLOGLEVEL=0 -O3  -I/home/home01/scnhv/SlenderBody/Python/Dependencies/UAMMD_PSE_Python/uammd/           /src -I/home/home01/scnhv/SlenderBody/Python/Dependencies/UAMMD_PSE_Python/uammd/           /src/third_party -I/apps/developers/libraries/mkl/2019.0/1/gnu-8.3.0/include -L/apps/developers/libraries/mkl/2019.0/1/gnu-8.3.0/lib/intel64 -DUSE_MKL  -Xcompiler "-fPIC -w" -c /home/home01/scnhv/SlenderBody/Python/Dependencies/UAMMD_PSE_Python//uammd_wrapper.cu -o uammd_wrapper.o
nvcc fatal   : A single input file is required for a non-link phase when an outputfile is specified
make[1]: *** [uammd_wrapper.o] Error 1
make[1]: Leaving directory `/home/home01/scnhv/SlenderBody/Python/Dependencies/UAMMD_PSE_Python'
make: *** [UAMMD_PSE] Error 2
make: Leaving directory `/home/home01/scnhv/SlenderBody/Python'
(SlenderBody) [scnhv@login2.arc4 SlenderBody]$

My Cmake version is 2.8.12.2. I also tried to use a different version (3.26.4) of Cmake, but the problem still exists. I would be so grateful if you could kindly help me solve this issue.

Best regards, Nasrollah Hajaliakbari RAUL EDIT: Added backtics

RaulPPelaez commented 1 year ago

There is a space here and it should not be there:

 -I/home/home01/scnhv/SlenderBody/Python/Dependencies/UAMMD_PSE_Python/uammd/ /src 

Also here:

-I/home/home01/scnhv/SlenderBody/Python/Dependencies/UAMMD_PSE_Python/uammd/           /src/third_party

PS: encase your code/outputs in blocks delimited by three backtics (` ) so they are formatted

Nasrollah commented 1 year ago

Dear Dr. Paul P Pelaez,

Thanks for your comment and consideration. Based on that I edited makefile and now I reach to the stage that Dr. Ondrej Maxian mentioned needed to be fixed. I mean "LDLIBS=-mkl". I got this error:

"(SlenderBody) [scnhv@login2.arc4 SlenderBody]$ bash install.sh -DUAMMD_DEBUG -g -G
make: Entering directory `/home/home01/scnhv/SlenderBody/Python'
cd Dependencies/UAMMD_PSE_Python && make
make[1]: Entering directory `/home/home01/scnhv/SlenderBody/Python/Dependencies/UAMMD_PSE_Python'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/home01/scnhv/SlenderBody/Python/Dependencies/UAMMD_PSE_Python'
cd Dependencies/BatchedNBodyRPY && make
make[1]: Entering directory `/home/home01/scnhv/SlenderBody/Python/Dependencies/BatchedNBodyRPY'
make -C source
make[2]: Entering directory `/home/home01/scnhv/SlenderBody/Python/Dependencies/BatchedNBodyRPY/source'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/home01/scnhv/SlenderBody/Python/Dependencies/BatchedNBodyRPY/source'
make[1]: Leaving directory `/home/home01/scnhv/SlenderBody/Python/Dependencies/BatchedNBodyRPY'
cd cppmodules && make
make[1]: Entering directory `/home/home01/scnhv/SlenderBody/Python/cppmodules'
/apps/developers/compilers/gnu/8.3.0/1/default/bin/g++ -shared RPYKernelEvaluator.cpp -o RPYKernelEvaluator.so -Wall -O3 -std=c++11 -fPIC -fopenmp -mkl  `/home/home01/scnhv/.conda/envs/SlenderBody/bin/python3 -m pybind11 --includes`
g++: error: unrecognized command line option ‘-mkl’
make[1]: *** [RPYKernelEvaluator.so] Error 1
make[1]: Leaving directory `/home/home01/scnhv/SlenderBody/Python/cppmodules'
make: *** [cppfiles] Error 2
make: Leaving directory `/home/home01/scnhv/SlenderBody/Python'
(SlenderBody) [scnhv@login2.arc4 SlenderBody]$

I would be wondering if you could kindly guide me.

Best regards, Nasrollah Hajaliakbari

omaxian commented 1 year ago

Nasrollah,

I think when compiling with Intel (assuming you have the module loaded), you need to use icpc instead of g++. So change line 3 in this makefile (inside cppmodules) to CXX=icpc Then it should compile (assuming you did module load intel-2019 or however you load the intel compiler/library).

Thanks,

Ondrej maxian

Nasrollah commented 1 year ago

Dear Dr. Ondrej Maxian,

Thanks for your response. In fact, the problem was related to not loading module properly. I edited the makefile (attached here). makefile.txt I have successfully complied the code (which also have been attached here). Compilation_SlenderBody.txt I tried to run the example using this command ((SlenderBody) [scnhv@login2.arc4 SlenderBody]$ python3 MeasureG0.py) and I got this error:

" SlenderBody) [scnhv@login2.arc4 Examples]$ python3 MeasureG0.py Traceback (most recent call last): File "/home/home01/scnhv/SlenderBody/Python/Examples/MeasureG0.py", line 29, in exec(iLine); ^^^^^^^^^^^ File "", line 1, in IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/home01/scnhv/SlenderBody/Python/Examples/MeasureG0.py", line 44, in raise ValueError('This file takes three command line arguments: the seed (for CL network),\ ValueError: This file takes three command line arguments: the seed (for CL network),dt, the frequency omega to shear at, the maximum strain (on [0,1]), and l_p, in that order (SlenderBody) [scnhv@login2.arc4 Examples]$

"

i owuld be so pleased if you would guide me on this issue.

Kind regards, Nasrollah Hajaliakbari

omaxian commented 1 year ago

Nasrollah,

Great, I'm glad it compiled. I am sorry as I have not completely updated the documentation for some of the codes. The first thing that code (MeasureG0.py) does is load in this input file. You can see there that there are 4 arguments that are input from the command line. You can either input those as specified from the command line (that's helpful when you want to change the SLURM script but not the input file for different runs), or you can just change the input file so that there are no command line arguments. Hopefully that makes sense.

OM

Nasrollah commented 1 year ago

Dear Dr. Ondrej Maxian,

Thanks for your respone. I tried to run this example using this command:

"python MeasureG0.py 1 0.001 0.02 0.1 0.01"

But, unfortunately, I got a new error like this: " (SlenderBody) [scnhv@login2.arc4 Examples]$ python MeasureG0.py 1 0.001 0.02 0.1 0.001 Omega 0.020000: stopping time 500.000000, saveEvery 0.020000 Overwriting the number of oversampling points with Nx, since you selected direct quad /home/home01/scnhv/SlenderBody/Python/FibCollocationDiscretization.py:170: UserWarning: Your regularization wont do anything - youre using RPY warn('Your regularization wont do anything - youre using RPY') Eigenvalue threshold 0.00E+00 Traceback (most recent call last): File "/home/home01/scnhv/SlenderBody/Python/Examples/MeasureG0.py", line 71, in allFibers = fiberCollection(nFib,turnovertime,fibDisc,nonLocal,mu,omega,gam0,Dom,kbT,nThreads=nThr,rigidFibs=rigidDetFibs); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/home01/scnhv/SlenderBody/Python/fiberCollection.py", line 102, in init self._FibColCpp = FiberCollectionC(nFibs,self._NXpf,self._NTaupf,nThreads,self._rigid,\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: Mobility definition is ambiguous - can only specify one of exact RPY, oversampled RPY, or direct RPY

" I would be wondering if you could hlep me solve this issue as well.

Best regards, Nasrollah Hajaliakbari

Nasrollah commented 1 year ago

Dear Dr. Ondrej Maxian,

I think the problem is kind of related to this makefile (inside cppmodules) which does not compile some cpp libraries like (SpecialQuadratures.cpp, SingleFiberSaddlePointSolver.cpp, SingleFiberMobilityEvaluator.cpp, coeffs.cpp, VectorMethods.cpp and Chebyshev.cpp) and therefore, they are not created as objects. I would be wondering if you could kindly guide me on this issue as well.

Best regards, Nasrollah Hajaliakbari

omaxian commented 1 year ago

Nasrollah,

Sorry, there was a mistake on my end there, as I am still working on the documentation and introduced a small bug. I just committed a small change which will fix this. Please pull the changes down and it should work.

Thanks,

OM

Nasrollah commented 1 year ago

Dear Dr. Ondrej Maxian,

Tahnks for your reponse, patience and fixing the bug. I again tried to run the example using this command: " python MeasureG0.py 1 0.001 1 0.2 17.0". However, I got an error like this: " (SlenderBody) [scnhv@login2.arc4 Examples]$ python MeasureG0.py 1 0.001 1 0.2 17.0 Omega 1.000000: stopping time 10.000000, saveEvery 0.020000 Eigenvalue threshold 0.00E+00 Traceback (most recent call last): File "/home/home01/scnhv/SlenderBody/Python/Examples/MeasureG0.py", line 82, in allFibers.initFibList(fibList,Dom,XFile); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/home01/scnhv/SlenderBody/Python/fiberCollection.py", line 143, in initFibList AllX = np.loadtxt(XFileName) ^^^^^^^^^^^^^^^^^^^^^ File "/home/home01/scnhv/.conda/envs/SlenderBody/lib/python3.11/site-packages/numpy/lib/npyio.py", line 1356, in loadtxt arr = _read(fname, dtype=dtype, comment=comment, delimiter=delimiter, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/home01/scnhv/.conda/envs/SlenderBody/lib/python3.11/site-packages/numpy/lib/npyio.py", line 975, in _read fh = np.lib._datasource.open(fname, 'rt', encoding=encoding) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/home01/scnhv/.conda/envs/SlenderBody/lib/python3.11/site-packages/numpy/lib/_datasource.py", line 193, in open return ds.open(path, mode, encoding=encoding, newline=newline) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/home01/scnhv/.conda/envs/SlenderBody/lib/python3.11/site-packages/numpy/lib/_datasource.py", line 533, in open raise FileNotFoundError(f"{path} not found.") FileNotFoundError: BundlingBehavior/FinalLocsStericsBundlingLp17.0_Dt5e-06_1.txt not found. (SlenderBody) [scnhv@login2.arc4 Examples]$ " I think this problem is related to some last lines of this input file provided in below, which requires to set/provide some files. https://github.com/stochasticHydroTools/SlenderBody/blob/master/Python/Examples/StrainInputFile.txt#L41-L43

Are there required to be set by myself (if so, how I do this) or they should exist in the input directories? I would be wondering if you could guide me on this issue.

Best regards, Nasrollah Hajaliakbari

omaxian commented 1 year ago

Hi Nasrollah,

Right, the files MeasureG0.py (which does a strain relaxation test) and StrainDynamicNetwork.py (which computes stress in small amplitude oscillatory shear) both require an input. The reason for this is those files are measuring properties of the network, and we want the network to be in a steady state to accomplish this.

What you need to do is run the file FixedDynamicLinkNetwork.py, which uses the input file SemiflexBundleInputFile.txt . Running this will generate a set of output files, which can be used as input to MeasureG0.py and StrainDynamicNetwork.py. You can read more about this on the Examples page of the repo.

If you want to skip this step, you can take a look at lines 85-99 of FixedDynamicLinkNetwork.py, which will show you how to initialize from scratch without an output file. You can transfer this into whatever file you'd like to run.

Ondrej Maxian

Nasrollah commented 1 year ago

Dear Dr. Ondrej Maxian,

Thanks for your reply. Based on your info provided, I decided to first run this example https://github.com/stochasticHydroTools/SlenderBody/blob/master/Python/Examples/FixedDynamicLinkNetwork.py

This example aslo requires an input file, read from the end of this input file. As a result, it cannot be run standalone. I would be wondering if you could kindly provide a suitable file for that example. Consequently, I can use and run that example.

Kind regards, Nasrollah Hajaliakbari

omaxian commented 1 year ago

Nasrollah,

No, that example should not require any input files other than "SemiflexBundleInputFile.txt," which is already included in the repo for you.

OM

Nasrollah commented 1 year ago

Dear Dr. Ondrej Maxian,

Thanks for your response. I mean this line: https://github.com/stochasticHydroTools/SlenderBody/blob/master/Python/Examples/SemiflexBundleInputFile.txt#L40

Since I got this error: " (SlenderBody) [scnhv@login2.arc4 Examples]$ python FixedDynamicLinkNetwork.py 1 0.0001 17 Traceback (most recent call last): File "/home/home01/scnhv/SlenderBody/Python/Examples/FixedDynamicLinkNetwork.py", line 43, in copyInput = open(InputCopyName,'w') ^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: 'BundlingBehavior/SemiflexBundleInputFile_SegStericsBu ndlingLp17Dt_0.0001_1.txt' (SlenderBody) [scnhv@login2.arc4 Examples]$

"

Best regards, Nasrollah Hajaliakbari

omaxian commented 1 year ago

Nasrollah,

As it says in the docstring, you need to create a folder called "BundlingBehavior." So, before running, type mkdir BundlingBehavior

OM

Nasrollah commented 1 year ago

Dear Dr. Ondrej Maxian,

Thanks for your help and sorry for my misunderstanding. Now, it is running.

Best regards, Nasrollah Hajaliakbari

RaulPPelaez commented 1 year ago

@omaxian, I believe you should consider simply creating that folder if it does not exist:

os.makedirs(folder_name, exist_ok=True)