0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method

Last updated at Posted at 2025-01-30

サーバ上でCUDAが使えない

bottleやflaskなどのウェブフレームワークを使って作ったgunicornサーバ上でGPUを使おうとしたとき、下記エラーに遭遇したことはないでしょうか?

Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method

そんなときは、gunicornの代わりにgeventを使ってみてください。
例えばbottleの場合、

run(host="0.0.0.0",server="gunicorn",port=5000)

この部分を↓↓

run(host="0.0.0.0",server="gevent",port=5000)

このように変更するだけです。

※追記
geventだと複数ワーカーは動かないようで、ワーカー管理は別の枠組みが必要。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?