Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The type or namespace name 'TensorFlow' could not be found #1511

Closed
oddEventHorizon opened this issue Dec 20, 2018 · 16 comments
Closed

The type or namespace name 'TensorFlow' could not be found #1511

oddEventHorizon opened this issue Dec 20, 2018 · 16 comments
Assignees
Labels
help-wanted Issue contains request for help or information.

Comments

@oddEventHorizon
Copy link

oddEventHorizon commented Dec 20, 2018

Hi,

I've stumbled upon this problem when trying to experiment with ML Agents. I have noticed that few other people got stuck on it as well but none of them has really replied here with a solution that would help in my case or replied with any solution at all.

ISSUE:
When I put "ENABLE_TENSORFLOW" into the Scripting Define Symbols fields my VS Code is getting red all over the "using Tensorflow;" in TFSharpInferenceEngine.cs

Screenshot:
image

My setup:
ML Agents: v0.6 - had the same problem on v0.5 as well
Unity version: 2018.3.0f2 (official) - had this issue on 2018.3.0f1 (beta) as well
TF : 1.12
Python: 3.6.7
VS Code: 1.3 with: C#, Debugger for Unity, Unity Tools plugins.
.NET Frameworks: (perhaps I have too many of them)?
image
Project Settings:
image
I installed TFSharpPlugin (by double clicking it. And I keep it in a different folder than Unity if it made any difference... i'm becoming paranoid.. :))

I confirmed to have this issue on both of my projects (started new, clean one as well)

Any suggestions would be greatly appreciated. Thanks!

@13Flo
Copy link

13Flo commented Dec 20, 2018

As described here, make sure you installed that one:
https://s3.amazonaws.com/unity-ml-agents/0.5/TFSharpPlugin.unitypackage

That could be the source of your issue.

@oddEventHorizon
Copy link
Author

As described here, make sure you installed that one:
https://s3.amazonaws.com/unity-ml-agents/0.5/TFSharpPlugin.unitypackage

That could be the source of your issue.

Thanks for the reply, but I have installed TFSharpPlugin. I described it here in my initial post:

"I installed TFSharpPlugin (by double clicking it. And I keep it in a different folder than Unity if it made any difference... i'm becoming paranoid.. :))"

@13Flo
Copy link

13Flo commented Dec 20, 2018 via email

@louis030195
Copy link

I had this issue migrating from 0.5 to 0.6, and fixed it by reimporting TFsharp (on Ubuntu import package -> custom package) and it's located in Assets/Plugin
Where is your tfsharp imported ?

@oddEventHorizon
Copy link
Author

@13Flo - thanks for noticing it, however it did not fix my issue. I changed it to .NET Standrad 2.0 regardless as I'm not sure why it was changed.

@louis030195 - thank you for your reply.

The only reference of TFSharpPlugin I found was in here:

image

I double clicked the TFSharpPlugin.unitypackage file - assumed it will target itself correctly.

@awjuliani
Copy link
Contributor

Hi @oddEventHorizon

Do you get errors in the Unity Editor, or just in VS Code?

@awjuliani awjuliani added the help-wanted Issue contains request for help or information. label Dec 20, 2018
@awjuliani awjuliani self-assigned this Dec 20, 2018
@oddEventHorizon
Copy link
Author

oddEventHorizon commented Dec 20, 2018

Hi @oddEventHorizon

Do you get errors in the Unity Editor, or just in VS Code?

Hi.
No. Zero errors in Unity. I can even hit play button in one of the examples you've provided and game starts to simulate. However ML agents features are not working.

I have been trying desperately to find what broke it and potential workaround that I've came up with this.

When mentioned issue occurs in VS Code about tensorflow namespace or type not found, I open my Visual Studio 2017 Community. I open my project solution properties and I change:

Target Framework from: .NET Framework 4.5 to: .NET Framework 4.6.1

Then I go back to VS Code and all the compilation errors are gone. However If I close VS Code (that had no issues at the moment of closing) and I reopen it with Unity->Assets->Open C# Project - the problem occurs again.

It seems as if Unity was forcing .NET Framework 4.5 for some reason.

However as much as I'm happy that I have found a workaround I doubt it's a proper solution and I assume there is be some mistake that I'm making.

@13Flo
Copy link

13Flo commented Dec 20, 2018

That could be a good occasion to switch to Jetbrains Rider... ;)

@oddEventHorizon
Copy link
Author

@13Flo : yeah, but the price :)

@oddEventHorizon
Copy link
Author

Update:

I have noticed that until I change .NET Framework via Visual Studio Community 2017 I'm getting this printed out in the OmniSharp Log output window:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): Error: The primary reference "TensorFlowSharp" could not be resolved because it was built against the ".NETFramework,Version=v4.6.1" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5". C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): Error: The primary reference "System.Interactive.Async" could not be resolved because it was built against the ".NETFramework,Version=v4.6" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5".

I also almost certain that this issue was not occuring on Unity 2017 where I was able to specifically pick which .NET Framework 4.6 from the Scripting Runtime Version field in the Project Settings. In Unity 2018 you can only specify .NET Framework 4.x (equivalent). Maybe it's hardcoded to 4.5 somewhere?

@xiaomaogy
Copy link
Contributor

@awjuliani

@awjuliani
Copy link
Contributor

We have replaced TF# with our internal inference solution as of v0.7. Closing this issue for now. Please feel free to re-open if you deem it necessary.

@weiweitoo
Copy link

weiweitoo commented Apr 4, 2019

@awjuliani I am using the v0.7 ml-agent, and unity 2018.3.11. Still facing the same issue.
image

Step to reproduce the setup

  1. Do the same project configuration
    image
  2. Import from ml-agent/UnitySDK/Assets

@xiaomaogy
Copy link
Contributor

Hi @weiweitoo , since we got rid of TensorflowSharp, please remove the ENABLE_TENSORFLOW symbol, and it should be working.

@weiweitoo
Copy link

@xiaomaogy Cool. It works perfectly. Thanks!

@lock
Copy link

lock bot commented May 20, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help-wanted Issue contains request for help or information.
Projects
None yet
Development

No branches or pull requests

6 participants