问题描述
在blender渲染时使用gpu
bpy.context.scene.render.engine = 'CYCLES'
bpy.context.scene.cycles.device = 'GPU'
bpy.context.user_preferences.addons["cycles"].preferences.compute_device_type = 'CUDA'
在调用bpy.content的user_preferences的属性时显示没有这个属性,怀疑时版本更新这个属性被替换或者删掉了。
解决方法
将属性user_preferences改为preferences
bpy.context.scene.render.engine = 'CYCLES'
bpy.context.scene.cycles.device = 'GPU'
bpy.context.preferences.addons["cycles"].preferences.compute_device_type = 'CUDA'
#bpy.context.user_preferences.addons["cycles"].preferences.compute_device_type = 'CUDA'