Skip to content

如何使用cuda/gpu版本的libtorch #5674

Closed Answered by xq114
jalaxy33 asked this question in Q&A
Discussion options

You must be logged in to vote

用你的代码试了下

set_project("toytrain")
set_languages("cxxlatest")

add_rules("mode.debug", "mode.release")
set_runtimes("MD")

add_requires("cmake::Torch", {system = true, configs = {envs = {CMAKE_PREFIX_PATH = "C:\\Users\\xq114\\Downloads\\libtorch"},
                                                        presets = {CMAKE_BUILD_TYPE = "Release"}}})

target("toytrain")
    set_kind("binary")
    add_packages("cmake::Torch")
	add_files("src/main.cpp")
    add_ldflags("/INCLUDE:?warp_size@cuda@at@@YAHXZ", {force = true})

编译

> xmake -v
checking for cl.exe ... C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64\cl.exe
checking for the c++ compiler (cx…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@jalaxy33
Comment options

@xq114
Comment options

Answer selected by jalaxy33
@xq114
Comment options

@jalaxy33
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants