Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Rust中编译nvptx_Rust_Gpu_Nvidia - Fatal编程技术网

如何在Rust中编译nvptx

如何在Rust中编译nvptx,rust,gpu,nvidia,Rust,Gpu,Nvidia,我曾试图在Rust中借助于的帮助编译nvptx。这是我写的代码 使用std::time::Duration; 使用std::thread::sleep; #[cfg(target_arch=“nvptx”)] fn foo(){ println!(“呼叫”); 使用std::arch::nvptx::*; 不安全{ 设c=malloc(10); 睡眠(持续时间:从10万毫秒开始); 免费(c); } } fn main(){ #[cfg(target_arch=“nvptx”)] foo();

我曾试图在Rust中借助于的帮助编译nvptx。这是我写的代码

使用std::time::Duration;
使用std::thread::sleep;
#[cfg(target_arch=“nvptx”)]
fn foo(){
println!(“呼叫”);
使用std::arch::nvptx::*;
不安全{
设c=malloc(10);
睡眠(持续时间:从10万毫秒开始);
免费(c);
}
}
fn main(){
#[cfg(target_arch=“nvptx”)]
foo();
println!(“你好,世界!”);
}
我已经做了研究。 我认为可以通过执行
货物运行--target nvptx64 nvidia cuda
编译到nvptx。然而,当我试图运行它时,我收到了以下错误

error[E0463]: can't find crate for `std`.
  |.
  = note: the `nvptx64-nvidia-cuda` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `core_nvptx`.

To learn more, run the command again with --verbose.
error[E0432]: unresolved import `core::arch::nvptx`
 --> nvptx/src/lib.rs:4:5
  | use core::arch::nvptx
4 | use core::arch::nvptx;
  | ^^^^^^^^^^^^^^^^^ no `nvptx` in `arch`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.
error: could not compile `nvptx`.

To learn more, run the command again with --verbose.
因此,我将rust设置为nightly,并为nvptx添加了一个目标。
生锈目标添加nvptx64 nvidia cuda
。 所以我们加了一句
货物运输——目标nvptx64 nvidia cuda
。 我收到了与上面相同的错误

后记 我已经用以下文件结构创建了一个单独的nvptx板条箱

├─ Cargo.lock
├─ Cargo.toml
├─ nvptx
│ ├─ Cargo.lock
│ ├─ Cargo.toml
└─ src
└─ lib.rs
r└─ src
    r└─ main.rs
我在nvptx板条箱中创建了一个
.cargo/config
文件。 在信中,我写了以下内容

[build].
target = "nvptx64-nvidia-cuda".
下面是
nvptx/src/lib.rs
的内容

#![功能(stdsimd)]
#! [没有性病]!
使用core::arch::nvptx;
使用core::ffi::c_void;
不安全fn cuda_alloc(尺寸:usize)->*mut c_void{
nvptx::malloc(大小)
}
不安全fn cuda_免费(ptr:*多个c_无效){
nvptx::免费(ptr);
}
另外,
src/main.rs
中的代码如下所示

使用std::time::Duration;
使用std::thread::sleep;
使用nvptx::*;
fn foo(){
println!(“呼叫”);
不安全{
设ptr=cuda_alloc(使用时为10);
免费cuda_(ptr);
}
}
fn main(){
foo();
println!(“你好,世界!”);
}
当我编译这个时,我收到了以下错误

error[E0463]: can't find crate for `std`.
  |.
  = note: the `nvptx64-nvidia-cuda` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `core_nvptx`.

To learn more, run the command again with --verbose.
error[E0432]: unresolved import `core::arch::nvptx`
 --> nvptx/src/lib.rs:4:5
  | use core::arch::nvptx
4 | use core::arch::nvptx;
  | ^^^^^^^^^^^^^^^^^ no `nvptx` in `arch`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.
error: could not compile `nvptx`.

To learn more, run the command again with --verbose.
锈蚀版本: nightly-x86_64-unknown-linux-gnu(默认)
rustc 1.54.0-每晚(f94942d84 2021-05-19)

如果
rustup目标添加nvptx64 nvidia cuda
成功,我不相信你。检查again@Stargateur事实上,我已经更新了当前状态。