Visual Studio Code (VSCode) is a free code editor, which runs on the macOS, Linux, and Windows operating systems. It has elegent tooling support which supports Python & C++ development, visual debugging, integration with git and many more interesting features. Owing to the ease of use and extension management, it is a great editor for TensorFlow IO development. However, some effort is necessaryto configure it properly. Since VSCode configuration is very flexible, it allows developers to compile project using bazel and run the code under Python and C++ debuggers. The base tool setup might differ based on the operation systems, but the configuration approach should be similar.
Extensions
To install an extension click the extensions view icon (Extensions) on the Sidebar, or use the shortcut Ctrl+Shift+X. Then searh for keyword below.
- C/C++ - Official C++ extension from Microsoft
- Python - Official Python extension from Microsoft
- Python Extension Pack - another useful extension for Python development
Compiling projects
TensorFlow IO is compiled using bazel build command:
See project README file for details on how to setup development environment in Ubuntu.--compilation_mode dbg flag here indicates that produced binary should have debug symbols.Once you can compile project from command line, you can also configure VSCode to be able to invoke same command.
Open View->Command Pallete (Ctrl+Shift+P) and start typing: 'Tasks: Configure Build Task'.If you are doing this for the first time, editor is going to suggest creating tasks.json file.Once you have it, paste the following json:
Now, you can press Ctrl+Shift+B, and VSCode is going to use the command above to build the project.It uses its own terminal window, where all links are clickable. So when a compilation error occurs, you open the corresponding file and navigate to the line by just clicking on the link in the terminal window.
Visual Studio Installer. Use Visual Studio Installer to install Python with Visual Studio. Modify your Visual Studio Version, check Python development and click on the Modify button. Python will be installed to 'C: Program Files (x86) Microsoft Visual Studio Shared'. Add to path environment variable. Jul 26, 2019 I work on the Visual Studio C Compiler team. We are interested in helping TensorFlow upgrade to Visual Studio 2019 while also making sure the best compiler switches are being used. We have seen significant throughput and code generation improvements between the Visual Studio 2017 and the 2019 compilers across various projects. Visual Studio Code + Anaconda + Tensorflow + Debugging. Download & install Anaconda; Follow the steps in the following link to setup an environment with Tensorflow.
Hoping to use tensorflow function, (CNN deep learning function) to classify images with c coding in visual studio 2017. Nov 13, 2017 Open solution and train model Launch Visual Studio and select File Open Project/Solution. Select the Tensorflow Examples folder from the samples repository downloaded and open the TensorflowExamples.sln file. Find the MNIST project in Solution Explorer, right-click and select Set as StartUp.
Debugging projects
Debugging Python code is trivial, follow official documentation to figure out how to configure VSCode to enable that: https://code.visualstudio.com/docs/python/debugging
However, debugging C++ code requires GDB to be installed on your system. If you have a bq_sample_read.py
python script that uses tensorflow-io
library and is normally executed in the follow manner:
You can execute it under GDB using the following:
If the application crashes in the C++ code phase, you can run backtrace
in GDB console to get the stacktrace of the error.
VSCode also has GDB debugger support. It allows adding breakpoints, observe values of variables and step through the code in a step by step manner. To add debug configuration press the Debug View icon (Debug) on the Sidebar, or use the shortcut Ctrl+Shift+D. Here, press the little down arrow next to the play button and select 'Add Configuration..'. It will now create a launch.json
file, to which, please add the following config:
This makes it so there is an IP address on the Mac side and an IP address on the windows side. However some networks don't like giving 2 up addresses to the same Mac address. There is some settings you can change in parallels when windows is shut down to use a generated Mac address to get around this. Parallels toolbox download. For Mac & Windows Parallels ® Toolbox is our all-in-one solution with over 30 tools for macOS ® and Windows 10. With just one click, you can: Save Space on your Hard Drive. Jun 30, 2017 Parallels Toolbox for Windows is the straw that broke the camel's back. Cast your mind back to the halcyon days of PC software. You liked a piece of software, you paid the price, you got to keep said software in perpetuity. Parallels Toolbox: Like a Swiss Army Knife for your Mac. Posted by 1 month ago. Help Reddit App Reddit coins Reddit premium Reddit gifts.
If everything is configured correctly, you should be able to do Run -> Start Debugging (F5) or Run -> Run Without Debugging (Ctrl + F5). This will run your code under debugger:
In order to further simplify the debugging experience, you can configure GDB to skip standard C++ libraries. This allows you to ignore the code that you don't care about. To do this, create a ~/.gdbinit
file with the following content:
Formatting files
You can always reformat C++ or Python file by Right Click -> Format Document (Ctrl + Shift + I), but VSCode uses a different style convention. Luckily, it is easy to change.
For Python formatting, see https://donjayamanne.github.io/pythonVSCodeDocs/docs/formatting/
For C++ formatting, do the following:
- Go to Preferences -> Settings
- Search for 'C_Cpp.clang_format_fallbackStyle'
- Modify the
file:setting.json
file directly by adding the following content
TensorFlow 2 packages are available
tensorflow
—Latest stable release with CPU and GPU support (Ubuntu and Windows)tf-nightly
—Preview build (unstable) . Ubuntu and Windows include GPU support .
Older versions of TensorFlow
Surfshark vpn openvpn chrome. For TensorFlow 1.x, CPU and GPU packages are separate:
tensorflow1.15
—Release for CPU-onlytensorflow-gpu1.15
—Release with GPU support (Ubuntu and Windows)
System requirements
- Python 3.6–3.8
- Python 3.8 support requires TensorFlow 2.2 or later.
- pip 19.0 or later (requires
manylinux2010
support) - Ubuntu 16.04 or later (64-bit)
- macOS 10.12.6 (Sierra) or later (64-bit) (no GPU support)
- macOS requires pip 20.3 or later
- Windows 7 or later (64-bit)
- Raspbian 9.0 or later
- GPU support requires a CUDA®-enabled card (Ubuntu and Windows)
pip
. Hardware requirements
- Starting with TensorFlow 1.6, binaries use AVX instructions which may not run on older CPUs.
- Read the GPU support guide to set up a CUDA®-enabled GPU card on Ubuntu or Windows.
1. Install the Python development environment on your system
Check if your Python environment is already configured:
Requires Python 3.6–3.8, pip and venv >= 19.0 If these packages are already installed, skip to the next step.
Otherwise, install Python , the pip package manager , and venv :
Ubuntu
Tensorflow Visual Studio Code Windows
macOS
Install using the Homebrew package manager:
Windows
Install the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017, and 2019 . Starting with the TensorFlow 2.1.0 version, the msvcp140_1.dll
file is required from this package (which may not be provided from older redistributable packages). The redistributable comes with Visual Studio 2019 but can be installed separately:
- Go to the Microsoft Visual C++ downloads ,
- Scroll down the page to the Visual Studio 2015, 2017 and 2019 section.
- Download and install the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019 for your platform.
Make sure long paths are enabled on Windows.
Install the 64-bit Python 3 release for Windows (select pip
as an optional feature).
Raspberry Pi
Requirements for the Raspbian operating system:
Other
Caution: Upgrading the system pip can cause problems .If not in a virtual environment, use
python3 -m pip
for the commands below. This ensures that you upgrade and use the Python pip instead of the system pip . 2. Create a virtual environment (recommended)
Python virtual environments are used to isolate package installation from the system.
Ubuntu / macOS
Create a new virtual environment by choosing a Python interpreter and making a ./venv
directory to hold it:
Activate the virtual environment using a shell-specific command:
When the virtual environment is active, your shell prompt is prefixed with (venv)
.
Install packages within a virtual environment without affecting the host system setup. Start by upgrading pip
:
And to exit the virtual environment later:
Windows
Create a new virtual environment by choosing a Python interpreter and making a .venv
directory to hold it:
Activate the virtual environment:
Install packages within a virtual environment without affecting the host system setup. Start by upgrading pip
:
And to exit the virtual environment later:
Conda
While the TensorFlow provided pip package is recommended, a community-supported Anaconda package is available. To install, read the Anaconda TensorFlow guide .
3. Install the TensorFlow pip package
Choose one of the following TensorFlow packages to install from PyPI :
For Python formatting, see https://donjayamanne.github.io/pythonVSCodeDocs/docs/formatting/
For C++ formatting, do the following:
- Go to Preferences -> Settings
- Search for 'C_Cpp.clang_format_fallbackStyle'
- Modify the
file:setting.json
file directly by adding the following content
TensorFlow 2 packages are available
tensorflow
—Latest stable release with CPU and GPU support (Ubuntu and Windows)tf-nightly
—Preview build (unstable) . Ubuntu and Windows include GPU support .
Older versions of TensorFlow
Surfshark vpn openvpn chrome. For TensorFlow 1.x, CPU and GPU packages are separate:
tensorflow1.15
—Release for CPU-onlytensorflow-gpu1.15
—Release with GPU support (Ubuntu and Windows)
System requirements
- Python 3.6–3.8
- Python 3.8 support requires TensorFlow 2.2 or later.
- pip 19.0 or later (requires
manylinux2010
support) - Ubuntu 16.04 or later (64-bit)
- macOS 10.12.6 (Sierra) or later (64-bit) (no GPU support)
- macOS requires pip 20.3 or later
- Windows 7 or later (64-bit)
- Raspbian 9.0 or later
- GPU support requires a CUDA®-enabled card (Ubuntu and Windows)
pip
. Hardware requirements
- Starting with TensorFlow 1.6, binaries use AVX instructions which may not run on older CPUs.
- Read the GPU support guide to set up a CUDA®-enabled GPU card on Ubuntu or Windows.
1. Install the Python development environment on your system
Check if your Python environment is already configured:
Requires Python 3.6–3.8, pip and venv >= 19.0 If these packages are already installed, skip to the next step.
Otherwise, install Python , the pip package manager , and venv :
Ubuntu
Tensorflow Visual Studio Code Windows
macOS
Install using the Homebrew package manager:
Windows
Install the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017, and 2019 . Starting with the TensorFlow 2.1.0 version, the msvcp140_1.dll
file is required from this package (which may not be provided from older redistributable packages). The redistributable comes with Visual Studio 2019 but can be installed separately:
- Go to the Microsoft Visual C++ downloads ,
- Scroll down the page to the Visual Studio 2015, 2017 and 2019 section.
- Download and install the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019 for your platform.
Make sure long paths are enabled on Windows.
Install the 64-bit Python 3 release for Windows (select pip
as an optional feature).
Raspberry Pi
Requirements for the Raspbian operating system:
Other
Caution: Upgrading the system pip can cause problems .If not in a virtual environment, use
python3 -m pip
for the commands below. This ensures that you upgrade and use the Python pip instead of the system pip . 2. Create a virtual environment (recommended)
Python virtual environments are used to isolate package installation from the system.
Ubuntu / macOS
Create a new virtual environment by choosing a Python interpreter and making a ./venv
directory to hold it:
Activate the virtual environment using a shell-specific command:
When the virtual environment is active, your shell prompt is prefixed with (venv)
.
Install packages within a virtual environment without affecting the host system setup. Start by upgrading pip
:
And to exit the virtual environment later:
Windows
Create a new virtual environment by choosing a Python interpreter and making a .venv
directory to hold it:
Activate the virtual environment:
Install packages within a virtual environment without affecting the host system setup. Start by upgrading pip
:
And to exit the virtual environment later:
Conda
While the TensorFlow provided pip package is recommended, a community-supported Anaconda package is available. To install, read the Anaconda TensorFlow guide .
3. Install the TensorFlow pip package
Choose one of the following TensorFlow packages to install from PyPI :
tensorflow
—Latest stable release with CPU and GPU support (Ubuntu and Windows) .tf-nightly
—Preview build (unstable) . Ubuntu and Windows include GPU support .tensorflow1.15
—The final version of TensorFlow 1.x.
setup.py
file under REQUIRED_PACKAGES
. Virtual environment install
Verify the install:
System install
Verify the install:
Success: If a tensor is returned, you've installed TensorFlow successfully. Read the tutorials to get started.Package location
Tensorflow Visual Studio
A few installation mechanisms require the URL of the TensorFlow Python package. The value you specify depends on your Python version.
Visual Studio Code
Version | URL |
---|---|
Linux | |
Python 3.6 GPU support | https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.4.0-cp36-cp36m-manylinux2010_x86_64.whl |
Python 3.6 CPU-only | https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.4.0-cp36-cp36m-manylinux2010_x86_64.whl |
Python 3.7 GPU support | https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.4.0-cp37-cp37m-manylinux2010_x86_64.whl |
Python 3.7 CPU-only | https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.4.0-cp37-cp37m-manylinux2010_x86_64.whl |
Python 3.8 GPU support | https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.4.0-cp38-cp38-manylinux2010_x86_64.whl |
Python 3.8 CPU-only | https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.4.0-cp38-cp38-manylinux2010_x86_64.whl |
macOS (CPU-only) | |
Python 3.6 | https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.4.0-cp36-cp36m-macosx_10_9_x86_64.whl |
Python 3.7 | https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.4.0-cp37-cp37m-macosx_10_9_x86_64.whl |
Python 3.8 | https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.4.0-cp38-cp38-macosx_10_14_x86_64.whl |
Windows | |
Python 3.6 GPU support | https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-2.4.0-cp36-cp36m-win_amd64.whl |
Python 3.6 CPU-only | https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.4.0-cp36-cp36m-win_amd64.whl |
Python 3.7 GPU support | https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-2.4.0-cp37-cp37m-win_amd64.whl |
Python 3.7 CPU-only | https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.4.0-cp37-cp37m-win_amd64.whl |
Python 3.8 GPU support | https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-2.4.0-cp38-cp38-win_amd64.whl |
Python 3.8 CPU-only | https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.4.0-cp38-cp38-win_amd64.whl |
Raspberry PI (CPU-only) | |
Python 3, Pi0 or Pi1 | https://storage.googleapis.com/tensorflow/raspberrypi/tensorflow-2.3.0rc2-cp35-none-linux_armv6l.whl |
Python 3, Pi2 or Pi3 | https://storage.googleapis.com/tensorflow/raspberrypi/tensorflow-2.3.0rc2-cp35-none-linux_armv6l.whl |