Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

使用paddle.utils.cpp_extension.cpp_extension.CUDA_HOME前未检查 #433

nemon- started this conversation in General
Discussion options

非CUDA环境下,引入PaddleNLP,会在 paddlenlp\ops\ext_utils.py的19行报错,
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
原因应该是if not os.path.exists(CUDA_HOME):这行直接使用了CUDA_HOME而没有验证值。
查到在14-15行,有:
from paddle.utils.cpp_extension.cpp_extension import (
CUDA_HOME, CppExtension, BuildExtension as PaddleBuildExtension)
因此CUDA_HOME不是本包内的变量,不建议修改,因此建议修改\ext_utils.py的19行为:
if CUDA_HOME==None or not os.path.exists(CUDA_HOME):

You must be logged in to vote

Replies: 6 comments 1 reply

Comment options

多谢指出,我们进行修改完善~ ext_utils.py的19这里在paddle.utils.cpp_extension.cpp_extension返回的CUDA_HOME 是None的时候应该确实是会有问题的。

另外因为本地没有复现出来也确认了下paddle.utils.cpp_extension.cpp_extension返回的CUDA_HOME情况,https://github.com/PaddlePaddle/Paddle/blob/v2.1.0/python/paddle/utils/cpp_extension/extension_utils.py#L566 只有在不为空且不存在且是GPU版本的时候才会是None,对于CPU版本的Paddle应该也不太可能报错。

请问您这里当前报错的环境是怎样的呢,按照上面这样来讲的话应该CPU版本的Paddle应该也不太可能报错,我们看看能否先提供解决的方式

You must be logged in to vote
0 replies
Comment options

win7 64位,安装过VC_redist.x64.exe,python 3.7.4,paddle无GPU,paddle.version=='2.1.0',paddlenlp.version=='2.0.0',paddlehub.version=='2.1.0',pip install paddlehub没有报错,但是import paddlehub时出现以下提示:

import paddlehub
D:\dev\Python374\lib\site-packages\setuptools\depends.py:2: DeprecationWarning:
the imp module is deprecated in favour of importlib; see the module's documentat
ion for alternative uses
看报错信息最后3条:
from .transformer.decoding import *
File "D:\dev\Python374\lib\site-packages\paddlenlp\ops\transformer\decoding.py
", line 24, in
from paddlenlp.ops.ext_utils import load
File "D:\dev\Python374\lib\site-packages\paddlenlp\ops\ext_utils.py", line 19,
in
if not os.path.exists(CUDA_HOME):
File "D:\dev\Python374\lib\genericpath.py", line 19, in exists
os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneT
ype
于是发现了这个问题。我解决的方法就是修改\ext_utils.py的19行加上None的判断:
if CUDA_HOME==None or not os.path.exists(CUDA_HOME):

You must be logged in to vote
0 replies
Comment options

了解了,Windows的话可能确实会有些问题,https://github.com/PaddlePaddle/Paddle/blob/v2.1.0/python/paddle/utils/cpp_extension/extension_utils.py#L561 ,这里对于Windows的没有CUDA环境的返回的会是None,这个我们尽快修复下,您那边也可先行通过设置下CUDA_HOME或者CUDA_PATH环境变量为任意路径先行绕过您遇到的问题使用。

You must be logged in to vote
0 replies
Comment options

已修复,可以更新使用

You must be logged in to vote
0 replies
Comment options

经 pip install paddlenlp --upgrade ,升级到paddlenlp 2.0.1,验证通过。
辛苦各位了!

You must be logged in to vote
0 replies
Comment options

@nemon- 欢迎持续关注并给我们个star吧 :)

You must be logged in to vote
1 reply
Comment options

star那是一定的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installation Issues of installation
Converted from issue

This discussion was converted from issue #425 on May 22, 2021 16:21.

AltStyle によって変換されたページ (->オリジナル) /