1
votes

I am trying to print out some information within a CUDA kernel using printfs to write code into the console that I can paste into another program to draw the geometric setup that I am working with. I have, however, trouble getting the locale to work. I am working under Linux Mint 18.1 with CUDA 9.0. When I printf from the C++ part of my program the numbers get printed as follows:

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

but using it from a CUDA kernel I get

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. My locale command prints:

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. 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. Does anyone know where that is and how to make it do what I want?

1

1 Answers

0
votes

It seems like Linux is very adamant on keeping the current language configuration as it is. 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. Not sure if all of those steps were necessary, but it fixed my problem.