Skip to content

Running examples: Dependency problems, Linux target, errors in codegen_nvvm #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
welahi opened this issue Jan 19, 2025 · 6 comments · Fixed by #190
Closed

Running examples: Dependency problems, Linux target, errors in codegen_nvvm #129

welahi opened this issue Jan 19, 2025 · 6 comments · Fixed by #190

Comments

@welahi
Copy link

welahi commented Jan 19, 2025

System: Alma Linux 8.10
CUDA: 12.6.3

I cloned the Rust-CUDA and tried to compile examples/cuda/cpu/add using cargo run, having Rust nightly installed. The rust-toolchain file makes rustup install 1.59.0-nightly. However, the log-crate, which is required in version 0.4.25, needs Rust 1.60.0 or higher.

Changing the toolchain nightly-2022-04-07 leads to a similar error, where openssl-sys v0.9.104 needs 1.63.0 or higher.

Then, I removed the toolchain-file to just use the newest version of the rustc. The problem with the dependencies was solved, but the buildscript of rustc_codegen_nvvm nags about the target. In the buildscript I found this uncommented match arm

// NOTE(RDambrosio016): currently disabled because of weird issues with segfaults and building the C++ shim
// "x86_64-unknown-linux-gnu" => "linux-x86_64",

Is Linux basically not supported?

I removed the comment and tried again, this time getting a bunch of errors while trying to compile codegen_nvvm. Some of them where solved running rustup component add rust-src rustc-dev llvm-tools-preview. However, I'm stuck here now:

  1. I still get the error that the extern crate rustc_attr could not be found, and the suggested solution is again to install the llvm tools, which I already did.
  2. More importantly, I get 104 other errors like use rustc_codegen_ssa::traits::BaseTypeMethods;: no BaseTypeMethods in traits in crates/rustc_codegen_nvvm/src/abi.rs:9:5, which I have no idea how to solve.

Does anyone know how to resolve the issues?

@jorge-ortega
Copy link
Collaborator

Hi @welahi. We've just got done updating the toolchain to night-2025-03-02. Do the latest changes resolve your issues?

@welahi
Copy link
Author

welahi commented Mar 14, 2025

Thanks for rebooting the project :) Disclaimer: I needed Rust-CUDA for a student project, which is over now; feel free to de-prioritize my issue.

rust_codegen_nvvm still makes problems. I've setup a new clean environment (new rust/cargo nightly installation, cloned Rust-CUDA repo just right now). I cdd into examples/cuda/cpu/add and run cargo build.

Please note that I'm still working on Linux, so i had to manually uncomment the "x86_64-unknown-linux-gnu" => "linux-x86_64" branch arm in line 57 in build.rs of rust_codegen_nvvm.

It seems that there is some trouble with finding the shared library, which was supposed to be build. Here's the detailed error message:

error: failed to run custom build command for `add v0.1.0 (/my/path/to/Rust-CUDA/examples/cuda/cpu/add)`

Caused by:
  process didn't exit successfully: `/my/path/to/Rust-CUDA/target/debug/build/add-136490b7a26d28dc/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=../../gpu/add_gpu

  --- stderr
  error: failed to run `rustc` to learn about target-specific information

  Caused by:
    process didn't exit successfully: `/my/path/to/.rustup/toolchains/nightly-2025-03-02-x86_64-unknown-linux-gnu/bin/rustc - --crate-name ___ --print=file-names -Zcodegen-backend=/my/path/to/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so '-Zcrate-attr=feature(register_tool)' '-Zcrate-attr=register_tool(nvvm_internal)' -Zcrate-attr=no_std -Zsaturating_float_casts=false '-Cllvm-args=-arch=compute_61 --override-libm' --target nvptx64-nvidia-cuda --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg -Wwarnings` (exit status: 1)
    --- stderr
    error: couldn't load codegen backend /my/path/to/Rust-CUDA/target/debug/deps/librustc_codegen_nvvm.so: libnvvm.so.4: cannot open shared object file: No such file or directory


  thread 'main' panicked at crates/cuda_builder/src/lib.rs:529:10:
  Did not find output file in rustc output
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@jorge-ortega
Copy link
Collaborator

I'm only one windows, but have encountered similar issues where the codegen backend failed to load due to my environment not being setup correctly. The docker file in our repo has a step in it to configure the loader to include the nvvm libs (see this line). Could you try that and see if that works?

@jorge-ortega
Copy link
Collaborator

I hit this today in our ubuntu24 container. I've tried adding the path to LD_LIBRARY_PATH and to ldconfig, but it's still not picking it up.

# ldconfig -p | grep libnvvm
        libnvvm.so.4 (libc6,x86-64) => /usr/local/cuda/nvvm/lib64/libnvvm.so.4
        libnvvm.so (libc6,x86-64) => /usr/local/cuda/nvvm/lib64/libnvvm.so
# ldd /usr/local/cuda/nvvm/lib64/libnvvm.so
        linux-vdso.so.1 (0x00007ffc6c856000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f3542005000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f3542000000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3541ffb000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3541f12000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3541d00000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f3545e31000)

Can anyone else try running cargo build -p add in the ubuntu24 container? I'm still trying to figure out how to trace why it fails to load, but haven't had any luck. @adamcavendish would be great if you could also repro this.

@adamcavendish
Copy link
Contributor

I hit this today in our ubuntu24 container. I've tried adding the path to LD_LIBRARY_PATH and to ldconfig, but it's still not picking it up.

# ldconfig -p | grep libnvvm
        libnvvm.so.4 (libc6,x86-64) => /usr/local/cuda/nvvm/lib64/libnvvm.so.4
        libnvvm.so (libc6,x86-64) => /usr/local/cuda/nvvm/lib64/libnvvm.so
# ldd /usr/local/cuda/nvvm/lib64/libnvvm.so
        linux-vdso.so.1 (0x00007ffc6c856000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f3542005000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f3542000000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3541ffb000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3541f12000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3541d00000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f3545e31000)

Can anyone else try running cargo build -p add in the ubuntu24 container? I'm still trying to figure out how to trace why it fails to load, but haven't had any luck. @adamcavendish would be great if you could also repro this.

Sure. I'll get add example revived later today.

@welahi
Copy link
Author

welahi commented Apr 15, 2025

Just as an update from my side: As I mentioned, my student project has been done for a while and now my access to the system where I set this up has been finally revoked; hence, I won't be able to try anything new and from my perspective this issue can be closed. I didn't close it because other people seem to have encountered similar issues, but feel free to close it when you think it is appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants