Giter Club home page Giter Club logo

Comments (14)

yuanzexi avatar yuanzexi commented on May 7, 2024

@xdqf2128 方便提供一下 你的 CMake command 吗?
类似于 https://github.com/Tencent/Forward/blob/master/VS2019.bat 里面的编译选项。另外,现在 Keras 默认使用 third_party 下的源码编译,可以不用添加 path\to\HDF5\1.12.0\cmake\hdf5CMAKE_PREFIX_PATH 中。

from forward.

xdqf2128 avatar xdqf2128 commented on May 7, 2024

@xdqf2128 方便提供一下 你的 CMake command 吗?
类似于 https://github.com/Tencent/Forward/blob/master/VS2019.bat 里面的编译选项。另外,现在 Keras 默认使用 third_party 下的源码编译,可以不用添加 path\to\HDF5\1.12.0\cmake\hdf5CMAKE_PREFIX_PATH 中。

cmake ..
-DTensorRT_ROOT=D:\Software\TensorRT-7.2.1.6.Windows10.x86_64.cuda-10.2.cudnn8.0\TensorRT-7.2.1.6
-DENABLE_LOGGING=OFF
-DENABLE_PROFILING=OFF
-DENABLE_DYNAMIC_BATCH=OFF
-DBUILD_PYTHON_LIB=OFF
-DPYTHON_EXECUTABLE=D:\Software\Anaconda3\envs\forward_1\python.exe
-DENABLE_TORCH=OFF
-DENABLE_TENSORFLOW=OFF
-DENABLE_KERAS=ON

本来-DBUILD_PYTHON_LIB=OFF我要设为ON的,但是cmake时报错说windows平台不能为ON,我就设为OFF了

from forward.

xdqf2128 avatar xdqf2128 commented on May 7, 2024

@xdqf2128 方便提供一下 你的 CMake command 吗?
类似于 https://github.com/Tencent/Forward/blob/master/VS2019.bat 里面的编译选项。另外,现在 Keras 默认使用 third_party 下的源码编译,可以不用添加 path\to\HDF5\1.12.0\cmake\hdf5CMAKE_PREFIX_PATH 中。

没有设置CMAKE_PREFIX_PATH,用的是默认的路径,但是生成的时候报了一个找不到文件的错误

from forward.

XuMicoder avatar XuMicoder commented on May 7, 2024

我也是差不多这样的情况,我编译的是tf,cmake .. -G "Visual Studio 15 2017" -A x64 -DENABLE_PROFILING=ON -DBUILD_PYTHON_LIB=OFF -DENABLE_TORCH=OFF -DENABLE_TENSORFLOW=ON -DENABLE_KERAS=OFF -DTensorRT_ROOT=D:\TensorRT-7.2.1.6 -DENABLE_UNIT_TESTS=ON
cmake没啥问题,生成报错
8>------ 已跳过生成: 项目: ALL_BUILD, 配置: Debug x64 ------
8>没有为此解决方案配置选中要生成的项目
========== 生成: 成功 4 个,失败 3 个,最新 0 个,跳过 1 个 ==========

from forward.

zhkuo24 avatar zhkuo24 commented on May 7, 2024

使用 vs2019.bat 脚本时,出现类似报错

-- Performing CXX Test OLD_HEADER_FILENAME - Failed
-- Performing CXX Test HDF_NO_NAMESPACE - Failed
-- Performing CXX Test HDF_NO_STD - Failed
-- Performing CXX Test BOOL_NOTDEFINED - Failed
-- Performing CXX Test NO_STATIC_CAST - Failed
-- Performing CXX Test CXX_HAVE_OFFSETOF - Failed
-- Configuring done
-- Generating done

@yuanzexi 请问这种一般是什么问题,谢谢

from forward.

yuanzexi avatar yuanzexi commented on May 7, 2024

@xdqf2128 从你的错误日志看来,无法将参数 1 从“initializer list”转换为“fwd::TrtLayerOutput &&” 这种错误一般来源于使用的较低版本的 gcc 或者 g++,从而导致这种 C++ 11 的特性无法解析。你可以看看 cmake 的时候使用的是不是正确的 C++ 编译器。建议像 @XuMicoder 一样使用 VS2017.bat 或者 VS2019.bat。Windows 下使用 CMAKE 需要加 -G "Visual Studio 15 2017" -A x64 这类平台配置。

from forward.

yuanzexi avatar yuanzexi commented on May 7, 2024

使用 vs2019.bat 脚本时,出现类似报错

-- Performing CXX Test OLD_HEADER_FILENAME - Failed
-- Performing CXX Test HDF_NO_NAMESPACE - Failed
-- Performing CXX Test HDF_NO_STD - Failed
-- Performing CXX Test BOOL_NOTDEFINED - Failed
-- Performing CXX Test NO_STATIC_CAST - Failed
-- Performing CXX Test CXX_HAVE_OFFSETOF - Failed
-- Configuring done
-- Generating done

@yuanzexi 请问这种一般是什么问题,谢谢

@zhkuo24 这种可以忽略,是一些 HDF5 项目的不重要的检查,Generating Done 即表示项目 Cmake 成功,可以尝试编译。

from forward.

xdqf2128 avatar xdqf2128 commented on May 7, 2024

@xdqf2128 从你的错误日志看来,无法将参数 1 从“initializer list”转换为“fwd::TrtLayerOutput &&” 这种错误一般来源于使用的较低版本的 gcc 或者 g++,从而导致这种 C++ 11 的特性无法解析。你可以看看 cmake 的时候使用的是不是正确的 C++ 编译器。建议像 @XuMicoder 一样使用 VS2017.bat 或者 VS2019.bat。Windows 下使用 CMAKE 需要加 -G "Visual Studio 15 2017" -A x64 这类平台配置。

感谢!将VS2019.bat做了如下修改:

if not exist build ( md build )

cd build

REM cmake .. -G "Visual Studio 16 2019" -A x64

cmake .. -G "Visual Studio 16 2019" -A x64 ^
-DTensorRT_ROOT=D:\Software\TensorRT-7.2.1.6.Windows10.x86_64.cuda-10.2.cudnn8.0\TensorRT-7.2.1.6 ^
-DENABLE_LOGGING=OFF ^
-DENABLE_PROFILING=OFF ^
-DENABLE_DYNAMIC_BATCH=OFF ^
-DBUILD_PYTHON_LIB=OFF ^
-DPYTHON_EXECUTABLE=D:\Software\Anaconda3\envs\forward_1\python.exe ^
-DENABLE_TORCH=OFF ^
-DENABLE_TENSORFLOW=OFF ^
-DENABLE_KERAS=ON

cd ..

编译效果跟之前一样,顺利完成并且带有test failed.
然后,用VS2019,并在属性中修改如下配置:
image
image
不知道以上配置是否起了作用,但是最终确实编译成功了!
10>------ 已启动生成: 项目: ALL_BUILD, 配置: Release x64 ------ 10>Building Custom Rule D:/Projects/tencent_forward/Forward/CMakeLists.txt ========== 生成: 成功 10 个,失败 0 个,最新 0 个,跳过 0 个 ==========

但是我又有了一个新的疑问:
image
编译出来的文件并没有python库,我要怎么在python中调用forward的接口?是否跟我的cmake命令中BUILD_PYTHON_LIB=OFF有关?但是如我将BUILD_PYTHON_LIB设置为ON,cmake时会报windows平台不支持,我要怎么才能在windows的python中调用forward?

CMake Error at CMakeLists.txt:70 (message):
  BUILD_PYTHON_LIB=ON is NOT SUPPORTED on WINDOWS platform.

from forward.

yuanzexi avatar yuanzexi commented on May 7, 2024

@xdqf2128 恭喜你编译成功~! 我们目前禁止了 PYTHON_LIB 在 Windows 上的使用,是因为目前 Forward 为了支持与 PyTorch 以及 PY_Tensorflow 这些库同时在 Python 上使用直接让 Forward 链接了 Python-Torch 与 Python-Tensorflow。而这种链接操作操作目前只适用于 Linux 平台。
如果真是想在 Windows 平台下使用 Forward-Python,需要修改几处 CMakeLists.txt,让 Forward-Python 链接 Libtorch 或者 Tensorflow_C。且这种方式无法支持 Python 下同时使用 Forward 与 PyTorch / Tensorflow,因为 Libtorch / Tensorflow_C 本身与它们相应的 PyTorch / Tensorflow 库有加载冲突。

from forward.

xdqf2128 avatar xdqf2128 commented on May 7, 2024

@xdqf2128 恭喜你编译成功~! 我们目前禁止了 PYTHON_LIB 在 Windows 上的使用,是因为目前 Forward 为了支持与 PyTorch 以及 PY_Tensorflow 这些库同时在 Python 上使用直接让 Forward 链接了 Python-Torch 与 Python-Tensorflow。而这种链接操作操作目前只适用于 Linux 平台。
如果真是想在 Windows 平台下使用 Forward-Python,需要修改几处 CMakeLists.txt,让 Forward-Python 链接 Libtorch 或者 Tensorflow_C。且这种方式无法支持 Python 下同时使用 Forward 与 PyTorch / Tensorflow,因为 Libtorch / Tensorflow_C 本身与它们相应的 PyTorch / Tensorflow 库有加载冲突。

我目前只需要模型推理的时候用,所以只用Forward也够了,那需要修改 CMakeLists.txt哪些地方呢?

from forward.

yuanzexi avatar yuanzexi commented on May 7, 2024

@xdqf2128 如下修改 Forward 目录下的 https://github.com/Tencent/Forward/blob/master/CMakeLists.txt
image
这里也附上附件
CMakeLists.txt
最终将生产的 .pyd 文件拷贝到工作目录下,相关依赖的动态库 dll 也需要拷贝或者添加路径让其可在加载时被找到,即可import forward。例如,在以下目录中打卡 cmd -> python -> import forward 即可
image

from forward.

xdqf2128 avatar xdqf2128 commented on May 7, 2024

@yuanzexi
替换了CMakeLists.txt,生成的文件中还是没有.pyd文件
image
然后生成时报了一个错误:

严重性	代码	说明	项目	文件	行	禁止显示状态
错误	LNK1181	无法打开输入文件“..\..\bin\Release\libhdf5.lib”	forward	D:\Projects\tencent_forward\Forward\build\source\py_fwd\LINK	1	

from forward.

yuanzexi avatar yuanzexi commented on May 7, 2024

@xdqf2128 我这边测试了一下,只 ENABLE_KERAS=ONBUILD_PYTHON_LIB=ON 的情况下,应该有生成以下文件:
image

你这里似乎没有生成 libhdf5.lib。可以看看这里是不是哪里没编译生成。可以清空 build 目录重新编译试试。

from forward.

xdqf2128 avatar xdqf2128 commented on May 7, 2024

@yuanzexi 清空build重新编译还是会报错,貌似项目没有正确地处理引用,导致有些项目没有生成,我手动将没有生成的项目生成了一下,最终全部生成成功。
image
非常感谢您耐心地指导,那我把此issue关闭了!

from forward.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.