当前位置:网站首页>Path and LD_ LIBRARY_ Example of path usage

Path and LD_ LIBRARY_ Example of path usage

2022-06-29 04:08:00 Master Yiwen

PATH This environment variable , Since I was a freshman , Young and ignorant ,“ I'll figure it out one day ”, This is all 5 Years have passed ,5 year ! You know I'm here 5 How did the year come about !!!

What's the use ? Just check it out , The only thing I can use is take Some executables Add path to PATH in
for instance

I'm referring to it :
1. ONNX-TensorRT Installation tutorial https://zhuanlan.zhihu.com/p/380950900
2. https://github.com/onnx/onnx-tensorrt

After executing the following code block :

cd onnx-tensorrt
mkdir build && cd build
cmake .. -DTENSORRT_ROOT=<path_to_trt> && make -j
// Ensure that you update your LD_LIBRARY_PATH to pick up the location of the newly built library:
export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH

stay build There will be an executable file under the path onnx2trt
When I was executing , It can only be carried out ./onnx2trt, It cannot be executed directly in other paths onnx2trt

therefore PATH It works :

export PATH=$(pwd):$PATH

This allows you to onnx2trt Add path to PATH in , It can be executed in any path onnx2trt, But this addition is only temporary , If you want to add it all the way to PATH in , It can be like this :

echo "export PATH=$(pwd):$PATH" >> ~/.bashrc
source ~/.bashrc #  Refresh the environment variables 

Be careful echo String
If there is a variable in the string , Single quotation marks are ignored , The double quotation marks will bring the variable into the string after parsing

There is another example ,CUDA After installation , We will be in ~/.bashrc Add two lines of code at the end :

export  PATH=/usr/local/cuda/bin:$PATH
export  LD_LIBRARY_PATH=/usr/local/cuda/lib64$LD_LIBRARY_PATH

After performing nvcc -V Look at CUDA Is the installation successful , And the first line above is the guarantee nvcc The path you are in can be directly searched to , It can be executed directly nvcc


The next line leads to LD_LIBRARY_PATH

and LD_LIBRARY_PATH Usage of , If it's not a developer , But just ordinary users , It doesn't usually work

LD_LIBRARY_PATH yes Linux/UNIX Environment variables used in the system . It is used to tell the dynamic link loader where to find a shared library for a specific application .

And the above is compiled onnx2trt after , There is such a line :

export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH

Is to add the current path to LD_LIBRARY_PATH , After performing python setup.py install You can find the installation path


alike , Compiling mmdeploy in

export LD_LIBRARY_PATH=$ONNXRUNTIME_DIR/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$TENSORRT_DIR/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$CUDNN_DIR/lib64:$LD_LIBRARY_PATH

take onnxruntime tensorrt cudnn The paths of have been added to LD_LIBRARY_PATH
In order to compile SDK You can find the path

OK, be it so

原网站

版权声明
本文为[Master Yiwen]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/180/202206290345210263.html