Main crate: darknet
Get the crate by adding the dependency to your Cargo.toml
.
toml
darknet-sys = "0.2"
If you clone the repository manually, run git submodule init && git submodule update --recursive
to get all submodules.
enable-cuda
: Enable CUDA (expects CUDA 10.x and cuDNN 7.x).enable-opencv
: Enable OpenCV.runtime
: Link to darknet dynamic library. For example, libdark.so
on Linux.buildtime-bindgen
: Generate bindings from darknet headers.By default, darknet-sys compiles and link to darknet statically. You can control the feature flags to change the behavior.
By default, it builds and links to darknet statically.
sh
cargo build
You can optionally enable CUDA and OpenCV features. Please read Build with CUDA section to work to CUDA properly.
sh
cargo build --features enable-cuda,enable-opencv
If you prefer to build with your darknet source, fill the source directory to the DARKNET_SRC
environment variable. It expects a CMakeLists.txt
in that directory.
sh
export DARKNET_SRC=/path/to/your/darknet/repo
cargo build
With runtime
feature, darknet-sys will not compile the darknet source code and instead links to darknet dynamically. If you are using Linux, make sure libdark.so
is installed on your system.
sh
cargo build --feature runtime
With buildtime-bindgen
feature, darknet-sys re-generates bindings from headers. It guesses the header file paths according to feature flags. The option is necessary only when darkent is updated or modified.
If you prefer to your (possibly modified) header files, fill the header directory to DARKNET_INCLUDE_PATH
environment variable.
Please check both CUDA 10.x and cuDNN 7.x are installed and versions are correct.
They are not installed to standard paths on most systems. Please add the CUDA library directory to LIBRARY_PATH
environment variable before building. For example on Ubuntu and CUDA 10.1,
sh
env LIBRARY_PATH=/usr/local/cuda-10.1/lib64
cargo build --features enable-cuda
MIT license.
Huge thanks to jerry73204