Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用0306fix2整合包进行API调用时,使用CPU进行推理而不是GPU #1081

Closed
kingki663 opened this issue May 12, 2024 · 5 comments
Closed

Comments

@kingki663
Copy link

  1. 使用了0306fix2整合包
  2. conda环境python3.10;pip install -r requirements.txt 安装了依赖并conda install ffmpeg
  3. 进行API调用时发现相较于webUI特别慢,于是print infer_device发现是CPU而不是GPU
    请问该如何解决
    image
    image
@yoyofx
Copy link

yoyofx commented May 12, 2024

不应该 web-ui 和 api 都是读 config.py 里面有这样的代码:

if torch.cuda.is_available():
    infer_device = "cuda"
else:
    infer_device = "cpu"

有可能整合包的话里面有runtime,你自己启动的话,安装的依赖torch可能是cpu版本导致的

@yoyofx
Copy link

yoyofx commented May 12, 2024

你可以用整合包里的python启动:
runtime/python api.py .......

@kingki663
Copy link
Author

你可以用整合包里的python启动: runtime/python api.py .......

是这样的,成功解决问题了👍谢谢你呀!🌹

@kingki663
Copy link
Author

不应该 web-ui 和 api 都是读 config.py 里面有这样的代码:

if torch.cuda.is_available():
    infer_device = "cuda"
else:
    infer_device = "cpu"

有可能整合包的话里面有runtime,你自己启动的话,安装的依赖torch可能是cpu版本导致的

我现在想使用仓库里fast_interence_的代码而不是整合包进行API调用,但是按照README配置conda环境好像只会使用CPU?请问一下,我需要如何才能使用GPU呢?🌹

@yoyofx
Copy link

yoyofx commented May 13, 2024

不应该 web-ui 和 api 都是读 config.py 里面有这样的代码:

if torch.cuda.is_available():
    infer_device = "cuda"
else:
    infer_device = "cpu"

有可能整合包的话里面有runtime,你自己启动的话,安装的依赖torch可能是cpu版本导致的

我现在想使用仓库里fast_interence_的代码而不是整合包进行API调用,但是按照README配置conda环境好像只会使用CPU?请问一下,我需要如何才能使用GPU呢?🌹

这个是环境依赖问题, 整合包帮你安装好所有依赖了. 你看看上面那段关键代码 pytorch是有很多版本的, 你要在你的环境中安装CUDA版本才能使用GPU. CUDA又分是 11,还是12. 你得结合你的硬件进行安装.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants