- Visual Studio Tools Download
- Visual Studio Code No Module Named Tensorflow
- Install Tensorflow Visual Studio Code
- Visual Studio Code Tensorflow Gpu
- Docker Tensorflow Visual Studio Code
- Visual Studio Code Failed To Load The Native Tensorflow Runtime
00:15 Installation von TensorFlow03:15 Installation von Keras03:25 Installation von Visual Studio CodeHast Du Bock auf Machine Learning und Artificial Intell. Setup Deep Learning environment: TensorFlow, Jupyter Notebook and Visual Studio Code Few days back, I decided to setup development environment for deep learning on my Windows 10 laptop. In this article, I would share my experience in setting up a system typically for Data Science developers. Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform.
目的 WindowsでVisual Studio Codeを使用したTensorflow開発をで行えるようにしてみる。 手順 1.Anacondaのインストール + Tensorflow 開発環境の構築 以下を参考にtensorflowの開発環境を構築。 Windows版AnacondaでTensorFlow環境構築 - Qiita 2.Visual Studio Codeのインストール ここからダウンロードしてインストールするだけ. Visual Studio Code 구성하기 Visual Studio Code(VSCode)는 macOS, Linux 및 Windows 운영 체제에서 실행되는 무료 코드 편집기입니다. Python 및 C 개발, 시각적 디버깅, git과의 통합 및 기타 다양하고 흥미로운 기능을 지원하는 우아한 도구 지원이 제공됩니다.
I would describe TensorFlow as an open source machine learning framework developed by Google which can be used to build neural networks and perform a variety of machine learning tasks. it works on data flow graph where nodes are the mathematical operations and the edges are the data in the form of tensor, hence the name Tensor-Flow.
Let’s run a classic HelloWorld program first and see if TensorFlow is running on .NET. I can’t think of a simpler way to be a HelloWorld.
Install the TensorFlow.NET SDK¶
TensorFlow.NET uses the .NET Standard 2.0 standard, so your new project Target Framework can be .NET Framework or .NET Core/ .NET 5. All the examples in this book are using .NET Core 3.1 and Microsoft Visual Studio Community 2019. To start building TensorFlow program you just need to download and install the .NET SDK (Software Development Kit). You have to download the latest .NET Core SDK from offical website: https://dotnet.microsoft.com/download.
New a project
New Project
Choose Console App (.NET Core)
Console App
Start coding Hello World¶
After installing the TensorFlow.NET package, you can use the usingstaticTensorflow.Binding
to introduce the TensorFlow .NET library.
TensorFlow 2.x enabled EagerMode
by default. About what eager mode is, I will introduce it in detail in the following chapters.
After CTRL + F5 run, you will get the output.
This sample code can be found at here.
This guide is a part of a series of articles that show you how to save a Keras model and use it for predictions in a Visual Studio C program.
The guide will walk you through using Tensorflow’s C API (libtensorflow) in Visual Studio. You will get the C binaries (dlls), then create a .lib file. We’ll setup a new Visual Studio Project to use these dlls, and then call the TF_Version() function to make sure everything is running fine.
The caveat of the method here is that you’re limited to the CUDA version the binaries were compiled with. The version of the libtensorflow files might change over time, so I will attempt to specify what version we’re using here.
I’m working with VS 2017 and libtensorflow 1.13.1
Lets get libtensorflow
Head to the libtensorflow page and get the zip file for Windows. Here are the two options as of 6/6/2019:
Windows | |
Windows CPU only | https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-1.13.1.zip |
Windows GPU only | https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-windows-x86_64-1.13.1.zip |
I prefer the GPU version, and that’s the one I will get. I’m working with version 1.13.1-GPU.
Extract and setup environment variables
Extract the libtensorflow files to a folder you like. I prefer short and simple folder paths, so I put my files in D:libtensorflow
I prefer setting up environment variables so that any project can find these files. This is optional, but if you’re following this guide, I recommend you stick to these steps.
Find the Environment Variables settings on Windows (type environment in the start menu):
Click the Environment Variables button
Add a new entry called TF_DIR to the user variables. We will use TF_DIR later in the Visual Studio Project.
Hit okay and save these new settings.
Generate a .lib file
While the tensorflow files come with a .dll, they’re missing a .lib, which must be generated. You can download my .lib here. We can do this using visual studio tools.
There are a few guides on how to do this.
Adrian Henke’s Blog, VLC guide, Stack Overflow
I prefer a variant of the VLC guide which should let us do this in a few quick commands.
First find VS tools under: Start->Programs->Microsoft Visual Studio->Tools
Alternatively, start Visual Studio 2017, and launch the Visual Studio Command Prompt under Tools->Visual Studio Command Prompt
Here run the following commands. The filenames are important. Not using tensorflow.def as the filename can cause issues. Change the path of your libtensorflow folder if needed.
Visual Studio Tools Download
Create your visual studio project
Now that you have the environment and .lib files ready, we can create our visual studio project (or use a project that you want to add libtensorflow to).
We’ll start with a C++ project, and use C code instead. There are other ways to create a C project, but I’ll move ahead with this for simplicity, the steps remain the same.
Set your project to 64 bit.
This is needed for libtensorflow. It runs only on 64 bit projects.
Find the project properties under Project->Properties->Configuration Manager. Set the project to x64 if you already have that option, otherwise click new and create a new solution platform, then set that to x64.
Visual Studio Code No Module Named Tensorflow
Add the dll to the project.
Some of this is sourced from the openCV guide on building a visual studio project.
Setting the environment variables (above) makes this a little easier.
Under Project->Properties, first go to the C++ groups General entry and under the “Additional Include Directories” add the path to your libtensorflow directory. We created an environment variable, so we can use $(TF_DIR). If you don’t have “C/C++” group, you should add any .c/.cpp file to the project.
You can either click the edit button, or just add $(TF_DIR) directly. To separate entries if you already have them, use the semicolon ;
Add the lib to the project
Next go to the Linker ‣ General and under the “Additional Library Directories” add the libs directory: $(TF_DIR)
Then you need to specify the libraries in which the linker should look into. To do this go to the Linker ‣ Input and under the “Additional Dependencies” entry add the name of all modules which you want to use: tensorflow.lib
Run the program
Add the following simple code to your program:
At this stage, hit F5 to build and run the program. If it builds and runs, you’re good to move on to the next step: Running predictions using tensorflow in C.
If it doesn’t build
You need to check that Visual Studio can find the .lib and the .h files (above), or that your code is correct.
IF IT BUILDS BUT CAN’T FIND DLLs
You’ll have to figure out which DLLs are missing:
tensorflow.dll
Install Tensorflow Visual Studio Code
Make sure you set up the environment variable correctly, and that tensorflow.dll is in that folder.
CUDART / CUBLAS / CUDNN
Visual Studio Code Tensorflow Gpu
This implies that you downloaded the GPU version of tensorflow, and the version of CUDNN or CUDA doesn’t match the version the tensorflow dll was compiled for.
Docker Tensorflow Visual Studio Code
For cudart / cublas you will need to install the correct version of CUDA based on the name of the missing file. For example cudart64_80.dll implies that version 8.0 of CUDA is missing. You can find this in the NVIDIA download archive.
For cudnn, follow similar steps to get the correct version from the CUDNN archive.
Visual Studio Code Failed To Load The Native Tensorflow Runtime
Note, both the above steps require sign up (free) at NVIDIA’s website.