ShannonAI / service-streamer

Boosting your Web Services of Deep Learning Applications.
Apache License 2.0
1.22k stars 187 forks source link

关于 streamer = Streamer(... cuda_devices=(0,1,2,3))时,gpu 0不被使用的问题 #91

Open WuZifan opened 2 years ago

WuZifan commented 2 years ago

当我按照教程去跑multi gpus的服务时,发现我的服务能够很好的在gpu 1,2,3上启动,但是无法在gpu 0 上进行启动。

调研后,发现在 managed_model.py 这个文件中,有一个设置cuda_visiable_device的方法:

@staticmethod
    def set_gpu_id(gpu_id=None):
        if gpu_id:
            os.environ["CUDA_VISIBLE_DEVICES"] = str(gpu_id)

注意这里的if 的判断条件,当gpu_id =0 时,也会被认为条件失败,从而不设置cuda; 因此,需要手动将其修改为 if gpu_id is not None.