GithubHelp home page GithubHelp logo

GPU dll about hello_tf_c_api HOT 5 CLOSED

neargye avatar neargye commented on June 12, 2024
GPU dll

from hello_tf_c_api.

Comments (5)

Neargye avatar Neargye commented on June 12, 2024

Hi @ardeal,

Check https://github.com/apivovarov/TF_C_API
#40
https://github.com/Neargye/tensorflow/releases for gpu dll

from hello_tf_c_api.

ardeal avatar ardeal commented on June 12, 2024

Hi Neargye,

Thanks for your reply!

I paste part of the code from https://github.com/apivovarov/TF_C_API as follows:

Does the following code config the GPU?
is there any explanation about the digits in the code?

  uint8_t config[] = {0x32,0xb,0x9,0x1f,0x85,0xeb,0x51,0xb8,0x1e,0xd5,0x3f,0x20,0x1};
  TF_SetConfig(opts, config, 13, status);

One more question?
I saw the following code. The code might be based on Tensorflow C++ dll, right?
Where is tensorflow C++ dll downloading URL?

#include "tensorflow/core/protobuf/config.pb.h"
......
  tensorflow::ConfigProto config = {};
  tensorflow::GPUOptions* gpu = config.mutable_gpu_options();
const char* pb_file = "test.pb";
  TF_Status* status = TF_NewStatus();
  TF_Graph* graph = TF_NewGraph();
  load_frozen_model(pb_file, graph, status);
  TF_SessionOptions* opts = TF_NewSessionOptions();
  // GPUOptions: per_process_gpu_memory_fraction=0.33, allow_growth=True
  uint8_t config[] = {0x32,0xb,0x9,0x1f,0x85,0xeb,0x51,0xb8,0x1e,0xd5,0x3f,0x20,0x1};
  TF_SetConfig(opts, config, 13, status);
  TF_Session* sess = TF_NewSession(graph, opts, status);
  TF_DeleteSessionOptions(opts);

Thanks,

from hello_tf_c_api.

ardeal avatar ardeal commented on June 12, 2024

Hi Neargye,

I am using VS2017, 2080Ti, CUDA10.1 on Windows 10.
I tried to run you code interface.cpp.
If I use CPU version dll, the code could be run correctly. now I am trying to run the code on GPU.

I switched to GPU version dll, and modified CreateSession function as follows.

I got the error message.

TF_Session* CreateSession(TF_Graph* graph, TF_SessionOptions* options, TF_Status* status)
{
	if (graph == nullptr)
	{
		return nullptr;
	}

	MAKE_SCOPE_EXIT(delete_status){ TF_DeleteStatus(status); };
	if (status == nullptr)
	{
		status = TF_NewStatus();
	}
	else
	{
		delete_status.dismiss();
	}

	MAKE_SCOPE_EXIT(delete_options){ DeleteSessionOptions(options);};
	if (options == nullptr)
	{
		options = TF_NewSessionOptions();
	}
	else
	{
		delete_options.dismiss();
	}

	//uint8_t config[] = { 0x32,0xb,0x9,0x1f,0x85,0xeb,0x51,0xb8,0x1e,0xd5,0x3f,0x20,0x1 };
	//TF_SetConfig(options, config, 13, status);

	//uint8_t config[11] = { 0x32, 0x09, 0x09, 0x9a, 0x99, 0x99, 0x99, 0x99, 0x99, 0xe9, 0x3f };
	//TF_SetConfig(options, (void*)config, 11, status);

	//uint8_t config[11] = { 0x32, 0x09, 0x09, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0xe3, 0x3f };
	//TF_SetConfig(options, (void*)config, 11, status);

	uint8_t intra_op_parallelism_threads = 1;
	uint8_t inter_op_parallelism_threads = 1;
	uint8_t buf[] = { 0x10,intra_op_parallelism_threads,0x28,inter_op_parallelism_threads };
	TF_SetConfig(options, buf, sizeof(buf), status);

	auto session = TF_NewSession(graph, options, status);

	
	if (TF_GetCode(status) != TF_OK)
	{
		DeleteSession(session);
		return nullptr;
	}

	return session;
}
2020-03-06 10:59:54.402698: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library nvcuda.dll
2020-03-06 10:59:54.445662: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties:
name: GeForce RTX 2080 Ti major: 7 minor: 5 memoryClockRate(GHz): 1.545
pciBusID: 0000:01:00.0
2020-03-06 10:59:54.452047: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check.
2020-03-06 10:59:54.456707: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1763] Adding visible gpu devices: 0
2020-03-06 10:59:54.584373: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1181] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-03-06 10:59:54.588609: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1187]      0
2020-03-06 10:59:54.591208: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1200] 0:   N
2020-03-06 10:59:54.594424: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1326] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 8786 MB memory) -> physical GPU (device: 0, name: GeForce RTX 2080 Ti, pci bus id: 0000:01:00.0, compute capability: 7.5)
2020-03-06 11:00:04.520153: F tensorflow/stream_executor/cuda/cuda_driver.cc:175] Check failed: err == cudaSuccess || err == cudaErrorInvalidValue Unexpected CUDA error: invalid argument

Thanks,

from hello_tf_c_api.

Xonxt avatar Xonxt commented on June 12, 2024

@ardeal hi,

Does the following code config the GPU?
is there any explanation about the digits in the code?
uint8_t config[] = {0x32,0xb,0x9,0x1f,0x85,0xeb,0x51,0xb8,0x1e,0xd5,0x3f,0x20,0x1};

I think I can answer this question, if you don't mind, because I was basically the one who came up with the solution. See this issue. I think Neargye added something there though, some additional flags.

Where is tensorflow C++ dll downloading URL?

I might be wrong, but I think the Tensorflow guys do not make it available for download at the moment, you have to compile from source code yourself.

I got the error message.

just a hunch, but have you installed the correct version of CUDA and cuDNN that correspond to the version of Tensorflow.dll you're using, as well as updated your CUDA drivers?

from hello_tf_c_api.

ardeal avatar ardeal commented on June 12, 2024

@Xonxt and @Neargye,

hi,

Many thanks for your answer!
I will try your GPU configuration code.

For the CUDA dirvers and etc., I would like to make the whole thing clear as follows:

  1. I have a trained weights model of deep learning neural network. The model could be correctly run on my computer on Python with GPU driver, CUDA, and cudnn.
  2. I would like to run the model with C++ on VS on windows 10 on the same computer. I could run model correctly on CPU with C++ and without GPU. My C++ code is almost the same as the code in interface.cpp file in Neargye's git repo.
  3. My next step is run the code with GPU, but I encoutered the upper issues.

Do you have more ideas about the issue I am facing?

Thanks,
Ardeal

from hello_tf_c_api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.