Matlab crashes when importing pytorch library
4 次查看(过去 30 天)
显示 更早的评论
I'm calling user-defined python module from matlab script that includes PyTorch library. The following line crashes Matlab:
def myfunc():
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
Any ideas on how to fix this?
Thanks in advance
0 个评论
回答(1 个)
Vignesh Murugavel
2021-8-1
Using out-of-process execution mode will avoid these conflicts. For this reason, using out-of-process mode is the best practice when using the Python Interface. Use the pyenv command to run in out-of-process mode.
>> pyenv("Version","<path to python executable>", "ExecutionMode", "OutOfProcess")
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call Python from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!