Cycles / CUDA detection fails when Blenders path contains umlauts. #37817

Closed
opened 2013-12-14 17:41:40 +01:00 by Thomas Dinges · 18 comments

System Information
Windows 7 x64, Geforce 540M

Blender Version
Broken: Blender 2.69.7

Short description of error
CUDA does not show up in the User Preferences, if Blender is located in a directory with umlauts. (like D:\blender_dev\install\blenderöä)

I am not sure where the exact error is, but it might be inside OIIO: this_program_path() uses GetModuleFileName() to retreive the path, I guess GetModuleFileNameW() should be used here.

I tried to hack something together and recompiled the OIIO lib, but the error in Cycles remained. So either my code is wrong or the problem is somewhere else.

diff --git a/src/libutil/sysutil.cpp b/src/libutil/sysutil.cpp
index 0c862bb..9bac5c1 100644
  - a/src/libutil/sysutil.cpp
+++ b/src/libutil/sysutil.cpp
@@ -73,6 +73,7 @@

#include "dassert.h"

 

#include "sysutil.h"

+#include "strutil.h"
 
 OIIO_NAMESPACE_ENTER
 {
@@ -234,8 +235,14 @@ Sysutil::this_program_path ()
         r = size;

#elif defined(_WIN32)

     // According to MSDN...
  • unsigned int size = sizeof(filename);
  • int r = GetModuleFileName (NULL, filename, size);
+	
+	wchar_t filename16[10240];
+	filename16[0] = 0;
+    unsigned int size = sizeof(filename16);
+    int r = GetModuleFileNameW (NULL, filename16, size);
+	
+	if (r > 0)
+        return Strutil::utf16_to_utf8(filename16);

#elif defined(FreeBSD) || defined(FreeBSD_kernel)

     int mib[4];
     mib[0] = CTL_KERN;


**System Information** Windows 7 x64, Geforce 540M **Blender Version** Broken: Blender 2.69.7 **Short description of error** CUDA does not show up in the User Preferences, if Blender is located in a directory with umlauts. (like D:\blender_dev\install\blenderöä\) I am not sure where the exact error is, but it might be inside OIIO: this_program_path() uses GetModuleFileName() to retreive the path, I guess GetModuleFileNameW() should be used here. I tried to hack something together and recompiled the OIIO lib, but the error in Cycles remained. So either my code is wrong or the problem is somewhere else. ``` diff --git a/src/libutil/sysutil.cpp b/src/libutil/sysutil.cpp index 0c862bb..9bac5c1 100644 ``` - a/src/libutil/sysutil.cpp ``` +++ b/src/libutil/sysutil.cpp @@ -73,6 +73,7 @@ ``` #include "dassert.h" ``` ``` #include "sysutil.h" ``` +#include "strutil.h" OIIO_NAMESPACE_ENTER { @@ -234,8 +235,14 @@ Sysutil::this_program_path () r = size; ``` #elif defined(_WIN32) ``` // According to MSDN... ``` - unsigned int size = sizeof(filename); - int r = GetModuleFileName (NULL, filename, size); ``` + + wchar_t filename16[10240]; + filename16[0] = 0; + unsigned int size = sizeof(filename16); + int r = GetModuleFileNameW (NULL, filename16, size); + + if (r > 0) + return Strutil::utf16_to_utf8(filename16); ``` #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) ``` int mib[4]; mib[0] = CTL_KERN; ```
Author
Owner

Changed status to: 'Open'

Changed status to: 'Open'
Author
Owner

Added subscriber: @ThomasDinges

Added subscriber: @ThomasDinges
Author
Owner

Added subscriber: @brecht

Added subscriber: @brecht

OIIO: this_program_path() is not used when Cycles runs from inside Blender. For standalone this fix seems like it would be needed though.

I suspect cuModuleLoad is the problem, I couldn't figure out from the documentation what kind of encoding it expects. Probably utf16 on Windows, but I made a quick patch to use cuModuleLoadData instead which should solve the problem: cycles_utf16_cuda_path.diff

I didn't test this, don't have a Blender build on Windows at the moment.

`OIIO: this_program_path()` is not used when Cycles runs from inside Blender. For standalone this fix seems like it would be needed though. I suspect `cuModuleLoad` is the problem, I couldn't figure out from the documentation what kind of encoding it expects. Probably utf16 on Windows, but I made a quick patch to use `cuModuleLoadData` instead which should solve the problem: [cycles_utf16_cuda_path.diff](https://archive.blender.org/developer/F41092/cycles_utf16_cuda_path.diff) I didn't test this, don't have a Blender build on Windows at the moment.
Author
Owner

I had to change 2 lines to be able to compile it in FILE *path_fopen()

std::wstring path_utf16 = Strutil::utf8_to_utf16(path);
std::wstring mode_utf16 = Strutil::utf8_to_utf16(mode);

The result still fails though.

I had to change 2 lines to be able to compile it in FILE *path_fopen() std::wstring path_utf16 = Strutil::utf8_to_utf16(path); std::wstring mode_utf16 = Strutil::utf8_to_utf16(mode); The result still fails though.

Added subscriber: @Sergey

Added subscriber: @Sergey

Is someone looking into this issue?

Is someone looking into this issue?
Author
Owner

Didn't checked further since Brechts patch.

Didn't checked further since Brechts patch.

This issue was referenced by blender/blender-addons-contrib@241fccaf6a

This issue was referenced by blender/blender-addons-contrib@241fccaf6a113963598e5ad040e7e72c857bea00

This issue was referenced by 241fccaf6a

This issue was referenced by 241fccaf6a113963598e5ad040e7e72c857bea00

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Closed by commit 241fccaf6a.

Closed by commit 241fccaf6a.

Added subscriber: @late-4

Added subscriber: @late-4

This fix did not work. I played around bit, and came up with this and it does not crash anymore:

static boost::filesystem::path to_boost(const string& path)
{

ifdef _MSC_VER

std::wstring path_utf16;
path_utf16.assign(path.begin(), path.end());
return boost::filesystem::path(path_utf16);

else

return boost::filesystem::path(path);

endif

}

static string from_boost(const boost::filesystem::path& path)
{

ifdef _MSC_VER

string s8;
std::wstring ws = path.wstring();
s8.assign(ws.begin(), ws.end());
return s8;

else

return path.string();

endif

}

This fix did not work. I played around bit, and came up with this and it does not crash anymore: static boost::filesystem::path to_boost(const string& path) { # ifdef _MSC_VER std::wstring path_utf16; path_utf16.assign(path.begin(), path.end()); return boost::filesystem::path(path_utf16); # else return boost::filesystem::path(path); # endif } static string from_boost(const boost::filesystem::path& path) { # ifdef _MSC_VER string s8; std::wstring ws = path.wstring(); s8.assign(ws.begin(), ws.end()); return s8; # else return path.string(); # endif }

Changed status from 'Resolved' to: 'Open'

Changed status from 'Resolved' to: 'Open'

I don't think we can simply assign a utf8 string to an utf16 string like that, that won't work for non-ascii characters as far as I know.

Committed a tweak to my fix, which works for me anyway:
{d980c3eccbd020a9ff7137659e7cbfbc5adb125d}

I don't think we can simply assign a utf8 string to an utf16 string like that, that won't work for non-ascii characters as far as I know. Committed a tweak to my fix, which works for me anyway: {d980c3eccbd020a9ff7137659e7cbfbc5adb125d}

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Brecht Van Lommel self-assigned this 2014-01-14 20:03:41 +01:00
Author
Owner

OSL works again, thanks, also no further GPU crashers.

OSL works again, thanks, also no further GPU crashers.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#37817
No description provided.