Unity-Technologies / ml-agents

The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement learning and imitation learning.
https://unity.com/products/machine-learning-agents
Other
17.18k stars 4.16k forks source link

RayPerceptionSensor related errors #5958

Closed Duarte-Rodrigues-Neroes closed 1 year ago

Duarte-Rodrigues-Neroes commented 1 year ago

Describe the bug The RayPerceptionSensor.cs file has errors associated with variable names not existing, error in float to int conversions, some methods don't exist as supposed.

To Reproduce Steps to reproduce the behavior:

  1. Download the most recent version of ML-agents, as explained in the guidelines. Unity will show the error right away, after starting the 3DBall example tutorial.

Console logs / stack traces ...\ml-agents-develop\com.unity.ml-agents\Runtime\Sensors\RayPerceptionSensor.cs(459,39): error CS0103: The name 'QueryParameters' does not exist in the current context com.unity.ml-agents\Runtime\Sensors\RayPerceptionSensor.cs(466,146): error CS1503: Argument 5: cannot convert from 'float' to 'int' ml-agents-develop\com.unity.ml-agents\Runtime\Sensors\RayPerceptionSensor.cs(470,122): error CS1503: Argument 4: cannot convert from 'float' to 'int' ml-agents-develop\com.unity.ml-agents\Runtime\Sensors\RayPerceptionSensor.cs(486,54): error CS1501: No overload for method 'ScheduleBatch' takes 5 arguments ml-agents-develop\com.unity.ml-agents\Runtime\Sensors\RayPerceptionSensor.cs(491,51): error CS1501: No overload for method 'ScheduleBatch' takes 5 arguments

Environment (please complete the following information):

Duarte-Rodrigues-Neroes commented 1 year ago

This error could be related to the most recent commit on the main branch - "Update to 2022.3 LTS and batched raycasts"

miguelalonsojr commented 1 year ago

The package was updated to use Unity 2022.3. The API for batched ray casts has changed a bit in 2022.3. Upgrading Unity to 2022.3 should fix the issue.

Duarte-Rodrigues-Neroes commented 1 year ago

Does that mean I cannot run ML-agents in a lower version of Unity?

miguelalonsojr commented 1 year ago

You can use any version that you want, if you install the last registry release from the package manager, which was 2.0.1. Keep in mind, that you'll have to also install the correct python versions as well. You can find this info on the releases page. https://github.com/Unity-Technologies/ml-agents/releases

For installing older versions from GitHub, you'll have to switch to the correct release branch, e.g. release 20, which was released for 2021.3. https://github.com/Unity-Technologies/ml-agents/releases/tag/release_20 If you want to use the bleeding edge available on the develop branch, then you'll have to upgrade to the editor version listed in package.json https://github.com/Unity-Technologies/ml-agents/blob/develop/com.unity.ml-agents/package.json.

Duarte-Rodrigues-Neroes commented 1 year ago

Thank you so much for the clarification. It is now clear what I should do :)

miguelalonsojr commented 1 year ago

Closing.

OmarVector commented 1 year ago

You can use any version that you want, if you install the last registry release from the package manager, which was 2.0.1. Keep in mind, that you'll have to also install the correct python versions as well. You can find this info on the releases page. https://github.com/Unity-Technologies/ml-agents/releases

For installing older versions from GitHub, you'll have to switch to the correct release branch, e.g. release 20, which was released for 2021.3. https://github.com/Unity-Technologies/ml-agents/releases/tag/release_20 If you want to use the bleeding edge available on the develop branch, then you'll have to upgrade to the editor version listed in package.json https://github.com/Unity-Technologies/ml-agents/blob/develop/com.unity.ml-agents/package.json.

May I ask what is the science behind forcing upgrade to 2022 to use the latest package version, despite sentis already working on 2021 as far as I'm concern

Our project heavly rely on webgl support, and upgrading to 2022 effect our performance a lot due to having to upgrade URP to newer version and many render features we have no longer working .

miguelalonsojr commented 1 year ago

There are some new features in the latest release of MLA the depend on 2022, unrelated to Sentis. As Unity evolves, so does MLA.

OmarVector commented 1 year ago

There are some new features in the latest release of MLA the depend on 2022, unrelated to Sentis. As Unity evolves, so does MLA.

Thanks for explanation, would be possible for those features to be optional?

In my imagination, ML agents hasnt updated for very long time, and most of the users who use it are mostly using old version of unity which difficult for sudden update... so we may expect at least we can still use the package without those exclusive feature for 2022 and up.

However, its just suggestion hopefully put in to account

Thank you:)

miguelalonsojr commented 1 year ago

What version of 2021 are you using? I can patch ML-Agents to exclude features related to 2022.3 and have it available on the develop branch. I also replied to your thread on the Sentis discussion board. https://discussions.unity.com/t/ml-agent-and-sentis-pipeline/282043/15 Reopenning.

OmarVector commented 1 year ago

What version of 2021 are you using? I can patch ML-Agents to exclude features related to 2022.3 and have it available on the develop branch. I also replied to your thread on the Sentis discussion board. https://discussions.unity.com/t/ml-agent-and-sentis-pipeline/282043/15 Reopenning.

We are using 2021.3.8f1

Really appreciated, lets continue the discussion here for easier collaboration :))

miguelalonsojr commented 1 year ago

@OmarVector So, I've made the changes to support running MLA with Sentis on 2021.3. It's on this branch: https://github.com/Unity-Technologies/ml-agents/tree/fix-remove-batched-raycasts-2021 Unfortunately, I will not be able to merge this into develop, as we do not want to explicitly add support for Unity versions older than 2022.3. Plus, these changes remove any errors with the ML-Agents package, but some of the example scenes do not work on 2021.3 since they've been updated to 2022.3. However, we'll keep this branch around for those that want to use MLA + Sentis in 2021.3.

You can always install ML-Agents from the github repo directly by using the following git url:

git+https://github.com/Unity-Technologies/ml-agents.git?path=com.unity.ml-agents#fix-remove-batched-raycasts-2021

and installing the package through the package manager git URL installation process. Give it a shot and let me know how it goes.

Thanks again for supporting ML-Agents! I'm closing this issue.

OmarVector commented 1 year ago

@OmarVector So, I've made the changes to support running MLA with Sentis on 2021.3. It's on this branch: https://github.com/Unity-Technologies/ml-agents/tree/fix-remove-batched-raycasts-2021 Unfortunately, I will not be able to merge this into develop, as we do not want to explicitly add support for Unity versions older than 2022.3. Plus, these changes remove any errors with the ML-Agents package, but some of the example scenes do not work on 2021.3 since they've been updated to 2022.3. However, we'll keep this branch around for those that want to use MLA + Sentis in 2021.3.

You can always install ML-Agents from the github repo directly by using the following git url:

git+https://github.com/Unity-Technologies/ml-agents.git?path=com.unity.ml-agents#fix-remove-batched-raycasts-2021

and installing the package through the package manager git URL installation process. Give it a shot and let me know how it goes.

Thanks again for supporting ML-Agents! I'm closing this issue.

It went well, the performance is much higher than the version of 2022 but I believe its due to URP version as well

for the performance compared to our 2021 version, is almost the same, I may consider slightly improvement ... its difficult to observe the difference compared to 2022 due to frame spikes on webgl due to GC... its always in range 30-50 FPS

Thank you for providing this custom version of sentis: ))