- Hands-On GPU Programming with Python and CUDA
- Dr. Brian Tuomanen
- 400字
- 2021-06-10 19:25:38
Creating an environment launch script (Windows)
Windows users will need to be particularly careful that both their Visual Studio and Anaconda Python environment variables are set up correctly in order to use PyCUDA; otherwise, Python will not be able to find NVIDIA's nvcc CUDA compiler or Microsoft's cl.exe C++ compiler. Fortunately, batch scripts are included that will set up these environments for us automatically, but we will have to be careful that these are executed each and every time we want to do GPU programming.
We will, therefore, create a batch script that will launch an appropriate IDE or command-line environment by calling these other two scripts in succession. (This script is also available at https://github.com/PacktPublishing/Hands-On-GPU-Programming-with-Python-and-CUDA/blob/master/2/launch-python-cuda-environment.bat.)
Be sure to first open up Windows Notepad, and follow along:
First, find where your vcvars.bat file for Visual Studio is; in the case of Visual Studio 2015, it is at C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat.
Type the following line into your text editor, and then press Enter:
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
We now need to call the Anaconda's activate.bat script to set up the Anaconda Python environment variables; the standard path is Anaconda2\Scripts\activate.bat. We have to further indicate where the Anaconda libraries are with an argument to this script. In my case, the second line in my launch script would be call "C:\Users\%username%\Anaconda2\Scripts\activate.bat" C:\Users\%username%\Anaconda2.
Finally, the last line of our batch script will launch whatever environment—IDE or command-line prompt—you prefer to program in, which will inherit all of the necessary environment and system variables the prior two scripts will set up. If you prefer the old standard DOS-style Command Prompt, this line should just be cmd. If you like to work from PowerShell, change this to powershell. It will be necessary to use the command line in some cases, particularly for accessing the command line pip and conda for updating your Python library.
Finally, save this file to your desktop with the filename launch-python-cuda-environment.bat. You can now launch our Python GPU programming environment by double-clicking this file.
(Keep in mind that if you wish to use the Jupyter Notebook or Spyder Python IDEs, you can simply launch these from the command line with jupyter-notebook or spyder, or alternatively, you can make a batch script that just replaces cmd with the appropriate IDE launch command.)
- Linux運維之道(第3版)
- Getting Started with oVirt 3.3
- WindowsServer2012Hyper-V虛擬化部署與管理指南
- 嵌入式應用程序設計綜合教程(微課版)
- 循序漸進學Docker
- Windows Vista融會貫通
- macOS效率手冊
- Java EE 8 Design Patterns and Best Practices
- Linux自動化運維:Shell與Ansible(微課版)
- Joomla! 3 Template Essentials
- Fedora 12 Linux應用基礎
- Social Data Visualization with HTML5 and JavaScript
- VMware Horizon View Essentials
- Learn CUDA Programming
- 大規(guī)模分布式系統(tǒng)架構與設計實戰(zhàn)