This repo contains two components:
inference_dllThis contains a C++ DLL that sets up CUDA and calls TensorRT. It provides a number of exported functions for use by Java.mod_neoforgeThis is the Java mod code that calls the inference.dll functions. It handles getting / setting blocks in Minecraft.
Version requirements:
- neoforge-21.1.77
- Minecraft-1.21.1
- TensorRT-10.5.0.18
- CUDA 12.6
TensorRT 10.5 requires an NVIDIA GPU with compute capability >= 7.5. This means it requires an RTX 2060 or better, a GTX 1660 Ti or better, an MX550 or better, or a Tesla T4 or better. See the support matrix. Check this Wikipedia table to find the compute capability of your GPU: Compute capability, GPU semiconductors and Nvidia GPU board products
This setup guide includes steps for building the .jar Java mod file as well as building the native executable.
- CMake: https://cmake.org/download/
- Java 21 JDK: https://www.oracle.com/java/technologies/downloads/#jdk21-windows
- CUDA 12.6: https://developer.nvidia.com/cuda-12-6-0-download-archive
- TensorRT 10.5: https://developer.nvidia.com/tensorrt/download/10x
- (Optional) Make: https://www.gnu.org/software/make/
You can check your environment configuration by running the following commands:
cmake --version
java --version
nvidia-smi
nvcc --version
dpkg -l | grep nvinfer
make --versionCheck tensorrt_linux_install_steps.md for TensorRT installation details.
-
Run
./gradlew build. After the build succeeds, the mod .jar file will be located atmod_neoforge/build/libs/buildwithbombs-0.2.1.jar. -
Build the inference library and test executable using CMake:
cd inference_dll mkdir build cd build cmake .. cmake --build . --config Release
This will produce
inference.dllin theinference_dll/build/Releasedirectory. -
Create a
rundirectory insidemod_neoforgeif it does not exist, and copy the generated DLL -
Download the ONNX model from the release page and place it in the
mod_neoforge/rundirectory. This contains the model parameters and must be located next toinference.dll. -
Make sure
inference.dllis able to find the TensorRT and CUDA dynamic libraries. Either copy all DLLs into themod_neoforge/rundirectory, or add the CUDA and TensorRT lib folders to the system path. -
Test the mod by running:
./gradlew runClient
-
Run
./gradlew build. After the build succeeds, the mod .jar file will be located atmod_neoforge/build/libs/buildwithbombs-0.2.1.jar. -
Build the inference library and test executable:
Option 1: Using Make (Recommended)
cd inference_dll # Build the shared library make lib
Option 2: Using CMake directly
cd inference_dll mkdir build cd build cmake .. cmake --build . --config Release
-
Copy the newly built library (
libinference.so) to the mod's run folder. Create therunfolder if it doesn't exist:cp libinference.so ../mod_neoforge/run
-
Download the ONNX model from the release page and place it in the
mod_neoforge/rundirectory. This contains the model parameters and must be located next tolibinference.so. -
Make sure
libinference.socan find the TensorRT and CUDA shared libraries. Either copy all required.sofiles intomod_neoforge/run, or add the TensorRT and CUDA library folders to your system path:export LD_LIBRARY_PATH=/usr/local/tensorrt-10.5/lib:$LD_LIBRARY_PATH
-
Test the mod by running:
./gradlew runClient
There are still some issues with the Linux aarch64 build. Before we fix them, you can try the following steps to build the mod.
-
following the steps in tensorrt_linux_install_steps.md to install TensorRT and CUDA.
-
Locate the following CUDA and TensorRT and copy them to your Minecraft run directory (the parent directory of /mods). (usually in
/usr/local/tensorrt-10.5/lib)- libnvinfer_builder_resource.so.10.5.0
- libnvinfer.so.10.5.0
(usually in
/usr/local/cuda-12.6/lib64)- libnvonnxparser.so
- libcudart.so.12
-
Place
buildwithbombs-0.2.1.jar(build from previous step) in the Minecraft/modsfolder -
Place
libinference.so(build from previous step) in the Minecraft run directory. -
Place ddim_single_update.onnx (from release page) in the Minecraft run directory.
-
Start the game. If it loads, you will be given "Diffusion TNT" items upon entering a world. Placing one of these blocks triggers the diffusion process.
once you move all the files to the run directory, your folder structure should be like this:
.
├── ddim_single_update.onnx
├── libcudart.so.12
├── libinference.so
├── libnvinfer_builder_resource.so.10.5.0
├── libnvinfer.so.10
├── libnvonnxparser.so
├── ···
├── mods
│ └── buildwithbombs-0.2.1.jar
└── versions
└── 1.21.1-NeoForge
- Start the game. If it loads, you will be given "Diffusion TNT" items upon entering a world. Placing one of these blocks triggers the diffusion process.
To test your TensorRT installation without running Minecraft, you can build and run a standalone test executable:
On Linux:
cd inference_dll
# Build the shared library libinference.so
make lib
# Build the test executable inference
make test
# Run the test
make run
# Clean all build files
make cleanOn Windows:
-
Build the shared library (inference.dll)
# Create a build directory for the shared library mkdir build_lib cd build_lib cmake .. cmake --build . --config Release
This will generate
inference.dllin the build_lib directory. -
Build the test executable
# Create a build directory for the test executable mkdir build_test cd build_test # This will automatically enable test mode without manual code changes cmake .. -DSTANDALONE_TEST=ON cmake --build . --config StandaloneTest
This will generate the
inferenceexecutable in the build_test directory. When building with STANDALONE_TEST=ON:- Test code is automatically enabled
- Console output is enabled (no log file redirection)
- No manual code changes are needed
-
Run the inference
./inference.exe
the test will build two parallel diffusion threads, and for each thread, it will diffuse 1000 timesteps.
In the end, you will see the output in the console like:
job: 0, step = X, sum = Y
job: 1, step = X, sum = Y
If you can see the step goes to 0, and the sum is not 0, then the installation of TensorRT is successful.
ERROR: Mod and diffusion engine don't match! Init failed.
That means you have different version of the mod and the diffusion engine. you should update your code by git pull and build buildwithbombs-0.2.1.jar again.
Join this server to try it out (no client-side mod required): mc.buildwithbombs.com 🧨