In this article, I will share some of my experience on installing NVIDIA driver and CUDA on Linux OS. Here I mainly use Ubuntu as example. Comments for CentOS/Fedora are also provided as much as I can.
| using System; | |
| namespace Algorithms | |
| { | |
| public static class LevenshteinDistance | |
| { | |
| /// <summary> | |
| /// Calculate the difference between 2 strings using the Levenshtein distance algorithm | |
| /// </summary> | |
| /// <param name="source1">First string</param> |
This was tested on a ThinkPad P70 laptop with an Intel integrated graphics and an NVIDIA GPU:
lspci | egrep 'VGA|3D'
00:02.0 VGA compatible controller: Intel Corporation Device 191b (rev 06)
01:00.0 VGA compatible controller: NVIDIA Corporation GM204GLM [Quadro M3000M] (rev a1)
A reason to use the integrated graphics for display is if installing the NVIDIA drivers causes the display to stop working properly.
In my case, Ubuntu would get stuck in a login loop after installing the NVIDIA drivers.
This happened regardless if I installed the drivers from the "Additional Drivers" tab in "System Settings" or the ppa:graphics-drivers/ppa in the command-line.
| I've tested it on Fedora 23 and Ubuntu 16.04. I'm using gcc-5.3.1, python-3.4, VS Code-1.14.0 | |
| You can debug mixed Python/C++ in the same GUI. It also works for MPI applications. You can switch between the debuggers and corresponding call stacks. | |
| 1. Packages needed | |
| 1) Visual Studio Code | |
| 2) Extensions for VS Code: | |
| "Python" from Don Jayamanne (I'm using 0.6.7) | |
| This allows VS Code act as the front end to debug python. | |
| This gives VS Code ability to attach to a python script that uses module "ptvsd". |
Updated 4/11/2018
Here's my experience of installing the NVIDIA CUDA kit 9.0 on a fresh install of Ubuntu Desktop 16.04.4 LTS.
| files.download('example.txt') # from colab to browser download |
Important I'd recommend you use at least a 16GB sd card. I tried it with an 8GB card and it baaaaarely fits. I had to uninstall a lot of packages and regularly clean up.
Go to https://www.raspberrypi.org/downloads/raspbian/ and download the Raspbian Stretch image (either one).
Use Etcher (from https://etcher.io/) to "burn" the image onto the SD card.
| import torch, torch.nn as nn, torch.nn.functional as F | |
| import numpy as np | |
| import torch.optim as optim | |
| # tied autoencoder using off the shelf nn modules | |
| class TiedAutoEncoderOffTheShelf(nn.Module): | |
| def __init__(self, inp, out, weight): | |
| super().__init__() | |
| self.encoder = nn.Linear(inp, out, bias=False) | |
| self.decoder = nn.Linear(out, inp, bias=False) |
This file serves a BKM to get better performance on CPU for PyTorch, mostly focusing on inference or deployment. Chinese version available here.
Right now, on PyTorch CPU path, you may choose to use 3 types of memory formats.
- torch.contiguous_format: default memory format, also referred as NHCW.
- torch.channels_last: also referred as NHWC.
- torch._mkldnn: mkldnn blocked format.
| /* | |
| What's the fastest way to read a file? | |
| fast_read is a program that reads a file into memory using multiple parallel threads | |
| with a stochastic hill climb optimizer to find the fastest thread count and block size. | |
| Example run (note the effect of page cache, read is basically memcpy after that point): | |
| $ ./fast_read iotest_6G.dat | |
| Opening file iotest_6G.dat for reading | |
| Reading 6442450944 bytes |