ZakuroLab / spacemesh-cuda

Spacemesh-cuda is a library for plot acceleration using CUDA-enabled GPUs.
MIT License
23 stars 12 forks source link

Windows Support for spacemesh-cuda #1

Open LiQing-Code opened 3 weeks ago

LiQing-Code commented 3 weeks ago

I am interested in using spacemesh-cuda on a Windows environment. I have a few questions regarding this:

  1. Windows Support: Does spacemesh-cuda currently support Windows? If not, are there any plans to support it in the future?

  2. Precompiled Binaries: If Windows is supported, would it be possible to provide precompiled binary files for Windows in the releases section of the repository?

  3. Compilation Instructions: If precompiled binaries are not available, could you provide detailed instructions on how to compile spacemesh-cuda for Windows? Specifically, any required dependencies, environment setup, and build steps would be greatly appreciated.

Thank you for your assistance and for your work on this project!

Lothar1812 commented 2 weeks ago

+1

tickinbuaa commented 2 weeks ago

We currently have no plans to support Windows. However, considering that the source code itself does not depend on platform-specific libraries, only a few modifications to the build-related code should be necessary. These modifications should mainly focus on the rust/src/build.rs and CMakeLists.txt files. If you encounter any issues while compiling on Windows, please provide detailed information.

tickinbuaa commented 1 week ago

Support for the Windows platform has been completed. If you still encounter any issues, please provide me with detailed error information.

ziyiz commented 5 days ago

Thank you for your time on this project. I tried the latest code to build from source on a Windows 11 environment but no luck I ran cargo check and got error:

PS C:\Users\xxx\Desktop\spacemesh-cuda\post-rs\ffi> cargo check
warning: C:\Users\xxx\Desktop\spacemesh-cuda\post-rs\ffi\Cargo.toml: `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition
(in the `post` library target)
   Compiling spacemesh-cuda v0.0.1 (https://github.com/ZakuroLab/spacemesh-cuda.git?rev=7910031510ef2a7c1a7e7bcfe96d0e38ea921866#79100315)
   Compiling post-cbindings v0.7.8 (C:\Users\xxx\Desktop\spacemesh-cuda\post-rs\ffi)
error: failed to run custom build command for `spacemesh-cuda v0.0.1 (https://github.com/ZakuroLab/spacemesh-cuda.git?rev=7910031510ef2a7c1a7e7bcfe96d0e38ea921866#79100315)`

Caused by:
  process didn't exit successfully: `C:\Users\xxx\Desktop\spacemesh-cuda\post-rs\target\debug\build\spacemesh-cuda-e81b0d8493ce8a11\build-script-build` (exit code: 101)
  --- stderr
  thread 'main' panicked at C:\Users\xxx\.cargo\registry\src\index.crates.io-6f17d22bba15001f\cmake-0.1.50\src\lib.rs:1098:5:

  command did not execute successfully, got: exit code: 1

  build script failed, must exit now
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

I use Powershell and 'cmake --version' shows 'cmake version 3.29.6'

tickinbuaa commented 4 days ago

Thank you for your time on this project. I tried the latest code to build from source on a Windows 11 environment but no luck I ran cargo check and got error:

PS C:\Users\xxx\Desktop\spacemesh-cuda\post-rs\ffi> cargo check
warning: C:\Users\xxx\Desktop\spacemesh-cuda\post-rs\ffi\Cargo.toml: `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition
(in the `post` library target)
  Compiling spacemesh-cuda v0.0.1 (https://github.com/ZakuroLab/spacemesh-cuda.git?rev=7910031510ef2a7c1a7e7bcfe96d0e38ea921866#79100315)
  Compiling post-cbindings v0.7.8 (C:\Users\xxx\Desktop\spacemesh-cuda\post-rs\ffi)
error: failed to run custom build command for `spacemesh-cuda v0.0.1 (https://github.com/ZakuroLab/spacemesh-cuda.git?rev=7910031510ef2a7c1a7e7bcfe96d0e38ea921866#79100315)`

Caused by:
 process didn't exit successfully: `C:\Users\xxx\Desktop\spacemesh-cuda\post-rs\target\debug\build\spacemesh-cuda-e81b0d8493ce8a11\build-script-build` (exit code: 101)
 --- stderr
 thread 'main' panicked at C:\Users\xxx\.cargo\registry\src\index.crates.io-6f17d22bba15001f\cmake-0.1.50\src\lib.rs:1098:5:

 command did not execute successfully, got: exit code: 1

 build script failed, must exit now
 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

I use Powershell and 'cmake --version' shows 'cmake version 3.29.6'

Can you successfully compile spacemesh-cuda? If not, could you provide detailed error information?

ziyiz commented 3 days ago

Thank you for your time on this project. I tried the latest code to build from source on a Windows 11 environment but no luck I ran cargo check and got error:

PS C:\Users\xxx\Desktop\spacemesh-cuda\post-rs\ffi> cargo check
warning: C:\Users\xxx\Desktop\spacemesh-cuda\post-rs\ffi\Cargo.toml: `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition
(in the `post` library target)
  Compiling spacemesh-cuda v0.0.1 (https://github.com/ZakuroLab/spacemesh-cuda.git?rev=7910031510ef2a7c1a7e7bcfe96d0e38ea921866#79100315)
  Compiling post-cbindings v0.7.8 (C:\Users\xxx\Desktop\spacemesh-cuda\post-rs\ffi)
error: failed to run custom build command for `spacemesh-cuda v0.0.1 (https://github.com/ZakuroLab/spacemesh-cuda.git?rev=7910031510ef2a7c1a7e7bcfe96d0e38ea921866#79100315)`

Caused by:
 process didn't exit successfully: `C:\Users\xxx\Desktop\spacemesh-cuda\post-rs\target\debug\build\spacemesh-cuda-e81b0d8493ce8a11\build-script-build` (exit code: 101)
 --- stderr
 thread 'main' panicked at C:\Users\xxx\.cargo\registry\src\index.crates.io-6f17d22bba15001f\cmake-0.1.50\src\lib.rs:1098:5:

 command did not execute successfully, got: exit code: 1

 build script failed, must exit now
 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

I use Powershell and 'cmake --version' shows 'cmake version 3.29.6'

Can you successfully compile spacemesh-cuda? If not, could you provide detailed error information?

Here is the full log:

PS C:\Users\xxx\Desktop\spacemesh-cuda\post-rs\ffi> cargo build --release
warning: C:\Users\xxx\Desktop\spacemesh-cuda\post-rs\ffi\Cargo.toml: `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition
(in the `post` library target)
   Compiling proc-macro2 v1.0.85
   Compiling windows_x86_64_msvc v0.52.5
   Compiling crossbeam-utils v0.8.20
   Compiling prettyplease v0.2.20
   Compiling rustix v0.38.34
   Compiling libc v0.2.155
   Compiling typenum v1.17.0
   Compiling serde_json v1.0.117
   Compiling semver v1.0.23
   Compiling clang-sys v1.8.1
   Compiling generic-array v0.14.7
   Compiling num-traits v0.2.19
   Compiling bindgen v0.69.4
   Compiling serde v1.0.203
   Compiling thiserror v1.0.61
   Compiling crunchy v0.2.2
   Compiling indexmap v1.9.3
   Compiling syn v1.0.109
   Compiling cl-sys v0.4.3
   Compiling winapi v0.3.9
   Compiling rayon-core v1.12.1
   Compiling radium v0.7.0
   Compiling blake3 v1.5.1
   Compiling eyre v0.6.12
   Compiling randomx-rs v1.3.0 (https://github.com/spacemeshos/randomx-rs?rev=d46bcd90e09428883e253b8203d6b311b0a07b91#d46bcd90)
   Compiling cbindgen v0.26.0
   Compiling anyhow v1.0.86
   Compiling spacemesh-cuda v0.0.1 (https://github.com/ZakuroLab/spacemesh-cuda.git?rev=7910031510ef2a7c1a7e7bcfe96d0e38ea921866#79100315)
   Compiling uint v0.9.5
   Compiling windows-targets v0.52.5
   Compiling windows-sys v0.52.0
   Compiling libloading v0.8.3
   Compiling primitive-types v0.12.2
   Compiling bitvec v1.0.1
   Compiling rustc_version v0.4.0
   Compiling quote v1.0.36
   Compiling crossbeam-epoch v0.9.18
   Compiling crossbeam-queue v0.3.11
   Compiling crossbeam-channel v0.5.13
   Compiling ocl-core v0.11.5
   Compiling syn v2.0.66
   Compiling crossbeam-deque v0.8.5
   Compiling num-traits v0.1.43
   Compiling ocl-core-vector v0.1.1
   Compiling num-complex v0.4.6
   Compiling enum_primitive v0.1.1
   Compiling crossbeam v0.8.4
   Compiling qutex v0.2.6
   Compiling block-padding v0.3.3
   Compiling crypto-common v0.1.6
   Compiling core_affinity v0.8.1
   Compiling rayon v1.10.0
   Compiling inout v0.1.3
   Compiling cipher v0.4.4
   Compiling aes v0.8.4
   Compiling errno v0.3.9
   Compiling home v0.5.9
   Compiling tempfile v3.10.1
   Compiling which v4.4.2
   Compiling darling_core v0.20.9
   Compiling serde_derive v1.0.203
   Compiling thiserror-impl v1.0.61
   Compiling mockall_derive v0.12.1
   Compiling darling_macro v0.20.9
   Compiling darling v0.20.9
   Compiling serde_with_macros v3.8.1
   Compiling mockall v0.12.1
   Compiling ocl v0.19.7
   Compiling scrypt-jane-sys v0.1.0 (https://github.com/spacemeshos/scrypt-jane-rs?branch=main#79634704)
   Compiling toml v0.5.11
   Compiling serde_with v3.8.1
   Compiling scrypt-jane v0.1.0 (https://github.com/spacemeshos/scrypt-jane-rs?branch=main#79634704)
   Compiling post-cbindings v0.7.8 (C:\Users\xxx\Desktop\spacemesh-cuda\post-rs\ffi)
error: failed to run custom build command for `spacemesh-cuda v0.0.1 (https://github.com/ZakuroLab/spacemesh-cuda.git?rev=7910031510ef2a7c1a7e7bcfe96d0e38ea921866#79100315)`

Caused by:
  process didn't exit successfully: `C:\Users\xxx\Desktop\spacemesh-cuda\post-rs\target\release\build\spacemesh-cuda-07756e9a49958c2a\build-script-build` (exit code: 101)
  --- stderr
  CMake Warning:
    Manually-specified variables were not used by the project:

      CMAKE_ASM_FLAGS
      CMAKE_ASM_FLAGS_RELEASE
      CMAKE_C_FLAGS
      CMAKE_C_FLAGS_RELEASE

  thread 'main' panicked at C:\Users\xxx\.cargo\registry\src\index.crates.io-6f17d22bba15001f\cmake-0.1.50\src\lib.rs:1098:5:

  command did not execute successfully, got: exit code: 1

  build script failed, must exit now
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

It stopped when compiling 'post-cbindings v0.7.8'. I do have cmake in my env, I guess there might be some module path issue. I saw similar issue here and I can try modify the build script a bit https://github.com/rust-lang/cmake-rs/issues/118

tickinbuaa commented 3 days ago

Can you use CMake to successfully compile the C++ code in spacemesh-cuda? From the error message, I can't see any detailed errors.

LiQing-Code commented 3 days ago

Can you use CMake to successfully compile the C++ code in spacemesh-cuda? From the error message, I can't see any detailed errors.

I have tried compiling the spacemesh-cuda code using CMake before and encountered many issues. While I was able to solve some of them, I still couldn't complete the compilation successfully.

tickinbuaa commented 3 days ago

Can you provide the error message you get when compiling the C++ code directly?

LiQing-Code commented 3 days ago

Can you provide the error message you get when compiling the C++ code directly?

I have stopped trying to compile it for now and didn't keep a record of the previous errors. I'm currently waiting for the library's author or someone else to provide precompiled binaries.

tickinbuaa commented 3 days ago

Sorry, we do not currently have plans to provide compiled binary files.

ziyiz commented 2 days ago

Can you use CMake to successfully compile the C++ code in spacemesh-cuda? From the error message, I can't see any detailed errors.

I can build spacemesh-cuda with CMake and get the spacemesh-cuda.lib with some tweaks: a. 'set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2")' b. skip building the test

But I still got errs when build post-rs with cargo, I'm not familier with rust, trying to figure out settings in cbindings process

ziyiz commented 2 days ago

Actually when I switched to git bash to build the lib, it gave me more info to narrow down the issue:

Building Custom Rule C:/Users/xxx/.cargo/git/checkouts/spacemesh-cuda-test-5dfbd5481bd83b17/7910031/CMakeLists.txt
    Compiling CUDA source file ..\..\..\..\..\..\..\..\..\.cargo\git\checkouts\spacemesh-cuda-test-5dfbd5481bd83b17\7910031\src\spacemesh.cu...

    C:\Users\xxx\Desktop\spacemesh-cuda\post-rs\target\release\build\spacemesh-cuda-22ab13b83af57fe5\out\build>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.0\bin\nvcc.exe"  --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64" -x cu   -I"C:\Users\xxx\.cargo\git\checkouts\spacemesh-cuda-test-5dfbd5481bd83b17\7910031\include" -I"C:\Users\xxx\.cargo\git\checkouts\spacemesh-cuda-test-5dfbd5481bd83b17\7910031\src" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.0\include"     --keep-dir x64\Release  -maxrregcount=0  --machine 64 --compile -cudart static -std=c++17 -arch=all -Xcompiler="/EHsc -Ob2"   -D_WINDOWS -DNDEBUG -D"CMAKE_INTDIR=\"Release\"" -D_MBCS -D"CMAKE_INTDIR=\"Release\"" -Xcompiler "/EHsc /W1 /nologo /O2 /Fd"C:\Users\xxx\Desktop\spacemesh-cuda\post-rs\target\release\build\spacemesh-cuda-22ab13b83af57fe5\out\build\Release\spacemesh-cuda.pdb" /FS   /MD " -o spacemesh-cuda.dir\Release\spacemesh.obj "C:\Users\xxx\.cargo\git\checkouts\spacemesh-cuda-test-5dfbd5481bd83b17\7910031\src\spacemesh.cu"
    nvcc fatal   : A single input file is required for a non-link phase when an outputfile is specified

I'll take a look at this error later