Open biochem-fan opened 5 years ago
Some (unofficial) tips for those who want to use WarpLib from Linux.
WarpLib
Use Mono 5.18 and csc, not msc.
csc
msc
Get it from https://github.com/dtegunov/liblion. Apply several changes I reported there:
Get it from https://github.com/dtegunov/gtom and compile to make libgtom.a.
libgtom.a
As reported in https://github.com/dtegunov/gtom/issues, some tests do not compile; just comment them out.
They should be disabled.
GPUAcceleration/Functions.h:
#define dllexport #define __declspec(x) #define __stdcall
Use fftw_malloc instead in GPUAcceleration/einspline/blip_create.c.
fftw_malloc
GPUAcceleration/einspline/blip_create.c
Use pre-compiled binary from Google https://www.tensorflow.org/install/lang_c.
--- a/WarpLib/Tools/TFHelper.cs +++ b/WarpLib/Tools/TFHelper.cs @@ -68,7 +68,8 @@ namespace Warp.Tools // extern TF_Session * TF_LoadSessionFromSavedModel (const TF_SessionOptions *session_options, const TF_Buffer [DllImport(NativeBinding.TensorFlowLibrary)] - static extern unsafe TF_Session TF_LoadSessionFromSavedModelOnDevice(TF_SessionOptions session_options, LLBuffer* run_options, string export_dir, string[] tags, int tags_len, TF_Graph graph, string device, TF_Status status); + static extern unsafe TF_Session TF_LoadSessionFromSavedModel(TF_SessionOptions session_options, LLBuffer* run_options, string export_dir, string[] tags, int tags_len, TF_Graph graph, LLBuffer* meta_graph_def, TF_Status status); @@ -94,9 +95,10 @@ namespace Warp.Tools var cstatus = TFStatus.Setup(status); unsafe { - var h = TF_LoadSessionFromSavedModelOnDevice(sessionOptions.handle, runOptions == null ? null : runOptions.LLBuffer, exportDir, tags, tags.Length, graph.handle, device, cstatus.handle); + var h = TF_LoadSessionFromSavedModel(sessionOptions.handle, runOptions == null ? null : runOptions.LLBuffer, exportDir, tags, tags.Length, graph.handle, null, cstatus.handle);
PROGRAM = GPUAcceleration.dll NVCC = nvcc NVCCFLAGS = --compiler-options "-fPIC -std=c++11 -mavx -march=native" -I/path/to/liblion -I../GPUAcceleration/include -I../GPUAcceleration/einspline OBJS = ../GPUAcceleration/Angles.o ../GPUAcceleration/Comparison.o ../GPUAcceleration/Device.o ../GPUAcceleration/ParticleCTF.o \ ../GPUAcceleration/Polishing.o ../GPUAcceleration/SparseEigen.o ../GPUAcceleration/Backprojection.o \ ../GPUAcceleration/Correlation.o ../GPUAcceleration/Einspline.o ../GPUAcceleration/ParticleMultiBody.o \ ../GPUAcceleration/Post.o ../GPUAcceleration/Symmetry.o ../GPUAcceleration/Bessel.o ../GPUAcceleration/Cubic.o \ ../GPUAcceleration/FFT.o ../GPUAcceleration/ParticleNMA.o ../GPUAcceleration/Projector.o ../GPUAcceleration/TomoRefine.o \ ../GPUAcceleration/BoxNet2.o ../GPUAcceleration/CubicGPU.o ../GPUAcceleration/FSC.o ../GPUAcceleration/ParticleShift.o \ ../GPUAcceleration/Raycast.o ../GPUAcceleration/Tools.o ../GPUAcceleration/CTF.o ../GPUAcceleration/Deconv.o ../GPUAcceleration/Memory.o \ ../GPUAcceleration/ParticleSoftBody.o ../GPUAcceleration/Shift.o ../GPUAcceleration/WeightOptimization.o \ ../GPUAcceleration/einspline/bspline_create.o \ ../../liblion/src/filename.o ../../liblion/src/backprojector.o ../../liblion/src/complex.o ../../liblion/src/ctf.o \ ../../liblion/src/euler.o ../../liblion/src/healpix_sampling.o ../../liblion/src/multidim_array.o \ ../../liblion/src/mask.o ../../liblion/src/projector.o ../../liblion/src/symmetries.o ../../liblion/src/funcs.o \ ../../liblion/src/numerical_recipes.o ../../liblion/src/fftw.o %.o: %.cpp $(NVCC) $(NVCCFLAGS) -c -o $@ $< %.o: %.cu $(NVCC) $(NVCCFLAGS) -c -o $@ $< $(PROGRAM): $(OBJS) $(NVCC) $(NVCCFLAGS) --shared -o $(PROGRAM) ../../gtom/build/lib/libgtom.a /path/to/relion/external/fftw/lib/libfftw3f.a $^ .PHONY: clean clean: rm -fr $(PROGRAM) $(OBJS)
This quick and dirty Makefile does not recompile the binary when the header file is modified.
~/local/mono-5.14/bin/csc -debug /t:library /out:WarpLib.dll /unsafe \ /reference:System.Drawing.dll /reference:Accord.dll /reference:Accord.Math.dll /reference:Accord.Math.Core.dll /reference:MathNet.Numerics.dll \ /reference:BitMiracle.LibTiff.NET.dll /reference:System.Numerics.dll \ ../WarpLib/GPUQueue.cs ../WarpLib/NMAMap.cs ../WarpLib/Tools/ByteReaderBE.cs ../WarpLib/Tools/Matrix3.cs \ ../WarpLib/Headers/DM4.cs ../WarpLib/Tools/ClusterTrieste.cs ../WarpLib/Tools/Matrix4.cs \ ../WarpLib/CPU.cs ../WarpLib/Headers/EM.cs ../WarpLib/Tools/FloatVectors.cs ../WarpLib/Tools/PhysicsHelper.cs \ ../WarpLib/CTF.cs ../WarpLib/Headers/Headers.cs ../WarpLib/ProcessingOptions.cs ../WarpLib/Tools/Helper.cs ../WarpLib/Tools/Quaternion.cs \ ../WarpLib/Cubic1D.cs ../WarpLib/Headers/MRC.cs ../WarpLib/Projector.cs ../WarpLib/Tools/ImageHelper.cs ../WarpLib/Tools/RandomNormal.cs \ ../WarpLib/Cubic1DShort.cs ../WarpLib/Headers/Raw.cs ../WarpLib/SoftMap.cs ../WarpLib/Tools/IntVectors.cs ../WarpLib/Tools/Symmetry.cs \ ../WarpLib/CubicGrid.cs ../WarpLib/Star.cs ../WarpLib/Tools/IOHelper.cs \ ../WarpLib/FSC.cs ../WarpLib/Image.cs ../WarpLib/Tools/Logger.cs ../WarpLib/Tools/XMLHelper.cs \ ../WarpLib/GPU.cs ../WarpLib/Movie.cs ../WarpLib/Tools/BenchmarkTimer.cs ../WarpLib/Tools/MathHelper.cs ../WarpLib/WarpBase.cs \ ../WarpLib/TensorFlowSharp/Buffer.cs ../WarpLib/TensorFlowSharp/Operations.g.cs ../WarpLib/TensorFlowSharp/Tensor.cs ../WarpLib/TensorFlowSharp/Variable.cs \ ../WarpLib/TensorFlowSharp/OperationsExtras.cs ../WarpLib/TensorFlowSharp/Queue.cs ../WarpLib/TensorFlowSharp/Tensorflow.cs \ ../WarpLib/NoiseNet3D.cs ../WarpLib/BoxNet2.cs ../WarpLib/BoxNet.cs ../WarpLib/Tools/TFHelper.cs ../WarpLib/Headers/Tiff.cs \ ../WarpLib/NoiseNet2D.cs
You need your own main.cs. Interesting functions to call are Movie.ProcessCTF and Movie.ProcessShift.
main.cs
Movie.ProcessCTF
Movie.ProcessShift
~/local/mono-5.14/bin/csc /unsafe /out:WarpConsole.exe /reference:WarpLib.dll /reference:CommandLine.dll main.cs
Can you also provide instructions what it takes to make M.exe (or M_console.exe) work on Linux ?
Some (unofficial) tips for those who want to use
WarpLib
from Linux.Use Mono 5.18 and
csc
, notmsc
.liblion
Get it from https://github.com/dtegunov/liblion. Apply several changes I reported there:
gtom
Get it from https://github.com/dtegunov/gtom and compile to make
libgtom.a
.As reported in https://github.com/dtegunov/gtom/issues, some tests do not compile; just comment them out.
Windows specific function signatures
They should be disabled.
GPUAcceleration/Functions.h:
Aligned malloc is not present in Linux
Use
fftw_malloc
instead inGPUAcceleration/einspline/blip_create.c
.Tensorflow C API
Use pre-compiled binary from Google https://www.tensorflow.org/install/lang_c.
GPUAccleration.dll
This quick and dirty Makefile does not recompile the binary when the header file is modified.
WarpLib.dll
Binary
You need your own
main.cs
. Interesting functions to call areMovie.ProcessCTF
andMovie.ProcessShift
.