简体   繁体   English

CUDA kernel printf 的语言环境

[英]Locale for CUDA kernel printf

I am trying to print out some information within a CUDA kernel using printf s to write code into the console that I can paste into another program to draw the geometric setup that I am working with.我正在尝试使用printf将代码写入控制台,我可以将这些代码粘贴到另一个程序中以绘制我正在工作的几何设置。 I have, however, trouble getting the locale to work.但是,我很难让语言环境正常工作。 I am working under Linux Mint 18.1 with CUDA 9.0.我在 Linux Mint 18.1 和 CUDA 9.0 下工作。 When I printf from the C++ part of my program the numbers get printed as follows:当我从程序的 C++ 部分printf时,数字打印如下:

printf("my value: %.3f\n", my_value); // prints 1.234 for example

but using it from a CUDA kernel I get但是从 CUDA kernel 使用它我得到

printf("my value: %.3f\n", my_value); // prints 1,234

This is the format used in Germany, but obviously computers don't understand the latter format.这是德国使用的格式,但显然计算机不理解后一种格式。 I need it to print with the .我需要它与. instead of the comma.而不是逗号。 I have tried manually setting my locale by putting the line我已经尝试通过放置该行来手动设置我的语言环境

export LC_NUMERIC="en_US.UTF-8"

into my .bashrc .进入我的.bashrc My locale command prints:我的locale命令打印:

LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_US.UTF-8
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=de_BE.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=de_BE.UTF-8
LC_NAME=de_BE.UTF-8
LC_ADDRESS=de_BE.UTF-8
LC_TELEPHONE=de_BE.UTF-8
LC_MEASUREMENT=de_BE.UTF-8
LC_IDENTIFICATION=de_BE.UTF-8
LC_ALL=

But that does not change the output from the CUDA kernel.但这不会改变 output 从 CUDA kernel。 I am not sure which other values to overwrite, without messing up default currency and so on.我不确定要覆盖哪些其他值,而不会弄乱默认货币等。 I also cannot find any information on setting locales within CUDA, so I assume it fetches that information from somewhere else.我也找不到关于在 CUDA 中设置语言环境的任何信息,所以我假设它从其他地方获取该信息。 Does anyone know where that is and how to make it do what I want?有谁知道那在哪里以及如何使它做我想要的?

It seems like Linux is very adamant on keeping the current language configuration as it is.似乎 Linux 非常坚持保持当前语言配置不变。 I managed to get the printout to be like I want it by uninstalling all other language packages that were installed, putting通过卸载已安装的所有其他语言包,我设法使打印输出与我想要的一样,将

export LANG=en_US.utf8

in my .bashrc and then rebooting the machine.在我的.bashrc中,然后重新启动机器。 Not sure if all of those steps were necessary, but it fixed my problem.不确定是否所有这些步骤都是必要的,但它解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM