CUDA Development with CLion

CLion from JetBrains provides very good support on CUDA development. This post will mainly talk about how to create a CUDA project in CLion in Windows and how to solve problem when using CUDA 11.2.

Prerequisites

Before creating CUDA project in CLion, please install the following softwares.

  • CUDA Toolkit 11.2 for Windows. Check this link.
  • Visual Studio 2019 Community. Check this link.

After installation, in CLion, make sure your Toolchain’s architecture is amd64.

Create CUDA Project In CLion

When creating new project in CLion, simply select “CUDA Executable” as the template.

Let’s modify the default main.cu and test if CUDA is working.

After build and run, you should see the following output.

Now CUDA is working in CLion project!

Trouble shooting

When having the issue related to vcvars64.bat…

At the beginning, I got the following issue

“Could not set up the environment for Microsoft Visual Studio using ‘C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat’

After some searching, the problem is due to %PATH% is too long. You need to remove the unnecessary paths from %PATH%. Actually, if you see any double quote in %PATH%, please also remove them.

When having the issue “Use of undeclared identifier cudaConfigureCall

I also saw the following issue,

You probably are using CUDA 11. In this version, the version.txt file was removed. Instead, version.json was introduced. To solve this issue, you can simply create a version.txt with following context and copy it to where the CUDA is installed.

After opening the CLion, the problem will be gone.

References

 

 

 

Build NPM Proxy Server on Nexus OSS 3.21

I had good experience with Nexus OSS 2.x and it was very easy to use. Based on it, the team built up Maven proxy server and Java private repository. The server had been served for many years and it helped team to finish thousands of builds without any problem.

To have better NPM repository support, it’s time to upgrade to a newer version of Nexus. Compared with JFrog’s Artifactory OSS, NPM and Gradle repository support is included in Nexus OSS version already.

Installation

The latest Nexus OSS version can be download from here. Unzip it and go to /bin folder to start it. I am using Windows 10, so Nexus OSS can be installed as a Windows Service. Then you can start/stop the Nexus OSS server in Services Management.

When server starts, you can access the web page, default is http://localhost:8081.

Note: For the first time run, there needs to update the admin user’s password. Follow the instructions to finish it.

Create NPM repository

By default, there are Maven repo (can be used by Gradle as well) and NuGet repo. To have a NPM repo, you need to manually create it.

Use “admin” to log into Nexus, Open “Repositories” page and click “Create repository“.

Select “npm proxy” in the Recipe list,

Put a name of the repository, such as “npm-all” and the “remote storage”.

Click “Create repository” to finish the creation. Now a npm proxy server is ready for serving. The repo URL is http://localhost:8081/repository/npm-all/.

NPM and Yarn Configuration

For npm and yarn, you can use the following commands to use this proxy server respectively.

All done!

Visual Studio Code – Better than Atom

之前推荐过Github的Atom,但之后它的表现不太让人满意,真的非常非常的慢!!

再之后就开始使用Visual Studio Code,非常惊艳的Microsoft产品,运行很快,各种插件也很全,还能跨平台。现在已经全面用它来替代Atom和Notepad++,大家也快去试试吧!😬

好用的Spacemacs!

作为Emacs粉,以前最麻烦的莫过于安装各种package和设置各种配置,常常把各种文件拷来拷去的。偶然的机会看到了Spacemacs这个项目,试用之后,感觉真是非常方便。

  • 安装简便,基本就是用git clone得到最新的版本,还可以简单的升级。
  • 默认的配置非常好用,反正比我之前的好,我在配置包丢在网盘上了。😁
  • 安装package非常简单,基本就是几条命令,再不用网上找各种包了。
  • 强大的个人定置,可以分Layer。但其实对我没什么用,基本的已经很好了。

Emacs粉应该果断试试,不会让你失望的!戳这!😋

 

Emacs Keybinding in Windows Everywhere!

Keybinding之争从来就没有消停过,有人爱VIM,有人喜Emacs,没有对错,只是习惯。我属后者。

如果一个IDE或Editor没有Emacs的Keybinding,会被我无情的唾弃,所以喜欢Eclipse (with Emacs+),所有Jetbrain的IDE(IDEA,Pycharm)。

最近发现一个强大的小软件XKeymacs(惭愧,才发现,-_-!!),可以让所有Windows Application使用Emacs Keybinding。

本人亲测,在Visual Studio里,基本的键位表现完美。戳这下载

 

Print more logging messages during debugging

Sometimes, in debug mode,  more logging messages could be very helpful. We can change code to add more logs. But it’s not efficient as the code need to be re-compiled and later some log message may need to be removed after debugging.

Java debugger provides very powerful way to achieve this, which allows to print more messages and even more.

Take Eclipse for example, here I have a simple HelloWorld to calculate the sum from 0 to 99. In debugging, I want to see how sum changed in the loop but I don’t want to stop application and click “Continue” every time.

12-12-2014 5-31-25 PM

So first, I added a break point on line 8. Next, I edited the “Breakpoint Properties”. In the conditional text input, you can print some message first and make the return of expression as false.

12-12-2014 5-35-40 PM

To return false will make debugger not stop at line 8, but just print the log messages I want.

12-12-2014 5-37-57 PM

You can see it’s totally non-intrusive. Actually, you can put more complicated statements there and also you can control when to return true or false. It’s very flexible. In other IDEs, such as JetBrains IDEA and Netbeans, there are similar functions.

Eclipse插件之EHEP

开发过程中偶然需要到查看Tar文件的格式,发现在Emacs里对Tar文件做了特别的处理,不能显然文件的原貌。网上搜索之后,发现Eclipse里有个很给力的插件。它就是EHEP。

安然很简单,用下面的Update Link,

http://ehep.sourceforge.net/update

当打开二进制文件时,在Editor中选择“Hex Editor“,

2014-11-04_12-01-52

然后就可以看到可爱的二进制文件了。

2014-11-04_12-03-40