xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.14k stars 782 forks source link

PyTorch C++ API binary compiled with xmake crashes #5289

Closed LeBron-Jian closed 4 months ago

LeBron-Jian commented 4 months ago

Xmake 版本

xmake version :xmake v2.7.3+HEAD.b35ff3118, A cross-platform build utility based on Lua Copyright (C) 2015-present Ruki Wang, tboox.org, xmake.io

操作系统版本和架构

Windows11

描述问题

Hi, I have improved the content of xmake.lua。

Today I created a manual_seed_test project.

我引入了torch::manual_seed,运行就会crash,但是编译通过

期待的结果

只是希望引入torch::manual_seed(42); 运行不crash

工程配置

Then the content of xmake.lua is as follows

-- set xmake minimum version
set_xmakever("2.7.3")

-- set common flags
set_languages("c++17")
set_warnings("more")

add_requires("cmake::Torch", {alias = "libtorch", system = true, configs = {shared=false, envs = {CMAKE_PREFIX_PATH = "D:/3rdparty/libtorch-win-shared-with-deps-2.3.1+cu118/libtorch"}}})
add_packages("libtorch")

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

target("manual_seed_test")
    set_kind("binary")
    add_files("src/*.cpp")

附加信息和错误日志

The contents of main.cpp are the same as before, as follows:

#include <iostream>

#include <torch/torch.h>

using namespace std;

int main(int argc, char** argv)
{
    try {
       torch::manual_seed(0);
        auto random_tensor = torch::rand({4, 3, 384, 288});
        std::cout << "Random tensor shape: " << random_tensor.sizes() << std::endl;
    } catch (std::exception &e) {
        std::cout << e.what() << std::endl;
    }

    return 0;
}

run code , as follows:

xmake b manual_seed_test && xmake r manual_seed_test

run result as follows:

checking for Microsoft Visual Studio (x64) version ... 2022
[ 25%]: cache compiling.release src\main.cpp
[ 50%]: linking.release manual_seed_test.exe
[100%]: build ok!
error: execv(D:\manual_seed_test\build\windows\x64\release\manual_seed_test.exe) failed(-1073741819)

The specific content of the project is as follows: image

waruqi commented 4 months ago

这边只负责维护 xmake 自身构建配置和编译问题,用户项目代码自身问题和崩溃,这边不处理,你可以自己研究解决。

Issues-translate-bot commented 4 months ago

Bot detected the issue body's language is not English, translate it automatically.


This side is only responsible for maintaining xmake's own build configuration and compilation issues. Problems and crashes of the user project code itself will not be dealt with here. You can research and solve them yourself.

LeBron-Jian commented 4 months ago

这边只负责维护 xmake 自身构建配置和编译问题,用户项目代码自身问题和崩溃,这边不处理,你可以自己研究解决。

好的,谢谢

Issues-translate-bot commented 4 months ago

Bot detected the issue body's language is not English, translate it automatically.


This side is only responsible for maintaining xmake's own build configuration and compilation issues. Problems and crashes in the user project code are not handled here. You can research and solve them yourself.

OK, thanks