# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: blog
#     language: python
#     name: blog
# ---

# # Setting up Tensorflow with Cuda and Nvidia on Ubuntu 20.04
#
# #### 23rd March 2021
#
# I found this to be a bit of a pain! Once again, not really knowing the first thing about what my computer does or how it works is a bit of a disadvantage. I am just going to go through the steps of how I bumbled through getting this to work (eventually). 
#
# ## My configuration
#
# I'm using a Dell Inspiron 5580, and Ubuntu 20.04 LSB. Some specifics: 
#
# - ```
# $ uname -a
# Linux will-Inspiron-5580 5.4.0-67-generic #75-Ubuntu SMP Fri Feb 19 18:03:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
# ```
#
# - ```
# $ sudo lshw -C Display
#   *-display                 
#        description: VGA compatible controller
#        product: UHD Graphics 620 (Whiskey Lake)
#        vendor: Intel Corporation
#        physical id: 2
#        bus info: pci@0000:00:02.0
#        version: 02
#        width: 64 bits
#        clock: 33MHz
#        capabilities: pciexpress msi pm vga_controller bus_master cap_list rom
#        configuration: driver=i915 latency=0
#        resources: irq:145 memory:a4000000-a4ffffff memory:80000000-8fffffff ioport:5000(size=64) memory:c0000-dffff
#   *-display
#        description: 3D controller
#        product: GP108M [GeForce MX150]
#        vendor: NVIDIA Corporation
#        physical id: 0
#        bus info: pci@0000:02:00.0
#        version: a1
#        width: 64 bits
#        clock: 33MHz
#        capabilities: pm msi pciexpress bus_master cap_list rom
#        configuration: driver=nvidia latency=0
#        resources: irq:16 memory:a2000000-a2ffffff memory:90000000-9fffffff memory:a0000000-a1ffffff ioport:4000(size=128) memory:a3000000-a307ffff
# ```

# ### Installing the Nvidia Drivers
#
# For some reason I ended up with an error like:
#
# - [nvidia-smi has failed because it couldn't communicate with the nvidia driver](https://forums.developer.nvidia.com/t/nvidia-smi-has-failed-because-it-couldnt-communicate-with-the-nvidia-driver-ubuntu-16-04/48635)
#
# I don't really know what that was all about but what I tried was basically to tear everything down and reinstall it all, which isn't really a great permenant solution because I suspect it will break the next time Ubuntu updates the kernels. Here are some of the things I tried:
#
# - Removed everything 
# ```
# $sudo tear everything down, removed cuda, removed cuda from my .profile and .bashrc
# ```
#
# - Reinstalled recommended drivers
#
# - Blacklisted nouveau driver
#
# - Turned my computer off and on again (multiple times)
#
# - Installed some new linux headers (which is the step that I think fixed things)
#
# ```
# $sudo apt-get whatever
# ```
#
# And now it works. What the hell.

# ### Installing Tensorflow and using the GPU
#
# In theory this requires getting the correct version of Cuda and using the Nvidia Cuda toolchain. However, Tensorflow suggests that the easiest way to get set up is to use docker, and since I've used docker before for other things, though I am not an expert, that was the simplest option for me. 

StarcoderdataJupyterScriptsDedupFiltered